Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the pre-commit hook checks #259

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v2.0.2'
- repo: https://github.com/hhatto/autopep8
rev: 'v2.3.1'
hooks:
- id: autopep8
args:
Expand All @@ -14,12 +14,12 @@ repos:
- --max-line-length=99

- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
rev: "5.13.2"
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: "6.0.0"
rev: "7.1.1"
hooks:
- id: flake8
args:
Expand All @@ -33,7 +33,7 @@ repos:
)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
rev: "v5.0.0"
hooks:
- id: end-of-file-fixer
- id: mixed-line-ending
Expand Down
12 changes: 6 additions & 6 deletions fmf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _merge_plus(self, data, key, value, prepend=False):
return

# Use the special merge for merging dictionaries
if type(data[key]) == type(value) == dict:
if isinstance(data[key], dict) and isinstance(value, dict):
self._merge_special(data[key], value)
return

Expand Down Expand Up @@ -275,13 +275,13 @@ def _merge_minus(self, data, key, value):
if key not in data:
return
# Subtract numbers
if type(data[key]) == type(value) in [int, float]:
if isinstance(data[key], (int, float)) and isinstance(value, (int, float)):
data[key] = data[key] - value
# Replace matching regular expression with empty string
elif type(data[key]) == type(value) == type(""):
elif isinstance(data[key], str) and isinstance(value, str):
data[key] = re.sub(value, '', data[key])
# Remove given values from the parent list
elif type(data[key]) == type(value) == list:
elif isinstance(data[key], list) and isinstance(value, list):
data[key] = [item for item in data[key] if item not in value]
# Remove given key from the parent dictionary
elif isinstance(data[key], dict) and isinstance(value, list):
Expand Down Expand Up @@ -750,10 +750,10 @@ def show(self, brief=False, formatting=None, values=None):
# List available attributes
for key, value in sorted(self.data.items()):
output += "\n{0}: ".format(utils.color(key, 'green'))
if isinstance(value, type("")):
if isinstance(value, str):
output += value.rstrip("\n")
elif isinstance(value, list) and all(
[isinstance(item, type("")) for item in value]):
[isinstance(item, str) for item in value]):
output += utils.listed(value)
else:
output += pretty(value)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def test_get(self):

def test_show(self):
""" Show metadata """
assert isinstance(self.wget.show(brief=True), type(""))
assert isinstance(self.wget.show(brief=True), str)
assert self.wget.show(brief=True).endswith("\n")
assert isinstance(self.wget.show(), type(""))
assert isinstance(self.wget.show(), str)
assert self.wget.show().endswith("\n")
assert 'tester' in self.wget.show()

Expand Down