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

Add some helpful flake8 plugins #136

Merged
merged 6 commits into from
Sep 28, 2022

Conversation

mkniewallner
Copy link
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Add some helpful flake8 plugins to the codebase:

Update code to comply with the new checks.

Raw list of suggestions:

  • flake8-bugbear:
deptry/module.py:51:68: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
deptry/module.py:51:109: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
  • flake8-comprehensions:
deptry/import_parser.py:26:26: C414 Unnecessary list call within sorted().
deptry/import_parser.py:37:23: C414 Unnecessary list call within sorted().
  • flake8-simplify:
deptry/dependency_getter/pyproject_toml.py:28:16: SIM201 Use 'dep != "python"' instead of 'not dep == "python"'
deptry/dependency_getter/pyproject_toml.py:52:9: SIM105 Use 'contextlib.suppress(KeyError)'
deptry/dependency_getter/pyproject_toml.py:56:9: SIM105 Use 'contextlib.suppress(KeyError)'
deptry/dependency_getter/pyproject_toml.py:71:39: SIM118 Use '"optional" in spec' instead of '"optional" in spec.keys()'
deptry/dependency_getter/pyproject_toml.py:78:39: SIM118 Use '"python" in spec' instead of '"python" in spec.keys()'
deptry/dependency_getter/pyproject_toml.py:78:67: SIM118 Use '"version" in spec' instead of '"version" in spec.keys()'
deptry/issue_finders/misplaced_dev.py:39:13: SIM102 Use a single if-statement instead of nested if-statements
deptry/import_parser.py:87:18: SIM101 Multiple isinstance-calls which can be merged into a single call for variable 'node'
deptry/import_parser.py:97:13: SIM102 Use a single if-statement instead of nested if-statements
deptry/import_parser.py:120:60: SIM201 Use 'module != exception' instead of 'not module == exception'
deptry/import_parser.py:125:19: SIM115 Use context handler for opening files
deptry/dependency_getter/requirements_txt.py:65:59: SIM907 Use 'Optional[Dependency]' instead of 'Union[Dependency, None]'
deptry/dependency_getter/requirements_txt.py:80:54: SIM907 Use 'Optional[str]' instead of 'Union[str, None]'
deptry/dependency_getter/requirements_txt.py:102:16: SIM210 Use 'bool(re.findall('\\[([a-zA-Z0-9-]+?)\\]', line))' instead of 'True if re.findall('\\[([a-zA-Z0-9-]+?)\\]', line) else False'
deptry/dependency_getter/requirements_txt.py:106:16: SIM210 Use 'bool(';' in line)' instead of 'True if ';' in line else False'
deptry/dependency_getter/requirements_txt.py:119:46: SIM907 Use 'Optional[str]' instead of 'Union[str, None]'

@fpgmaas fpgmaas merged commit 90160c1 into fpgmaas:main Sep 28, 2022
@fpgmaas
Copy link
Owner

fpgmaas commented Sep 28, 2022

Thanks for the contribution, looks good to me!

@mkniewallner mkniewallner deleted the add-flake8-plugins branch September 28, 2022 09:37
fpgmaas pushed a commit that referenced this pull request Oct 2, 2022
* chore(flake8): add `flake8-bugbear`
* chore: comply with `flake8-bugbear`
* chore(flake8): add `flake8-comprehensions`
* chore: comply with `flake8-comprehensions`
* chore(flake8): add `flake8-simplify`
* chore: comply with `flake8-simplify`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants