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 pyupgrade to pre-commit #174

Merged
merged 2 commits into from
Nov 7, 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

Description of changes

Add https://github.com/asottile/pyupgrade/ to our pre-commit hooks.

The library rewrites code to newer syntax of Python versions, which will prove useful the day we drop support for Python 3.7.
A nice feature of pyupgrade is also https://github.com/asottile/pyupgrade/#python2-and-old-python3x-blocks, which will rewrite a conditional import whenever the Python version in the condition is not supported anymore.

@mkniewallner mkniewallner requested a review from fpgmaas November 5, 2022 23:35
@@ -27,7 +27,7 @@ def extract(self, path_to_ipynb: Path) -> List[str]:

@staticmethod
def _read_ipynb_file(path_to_ipynb: Path) -> Dict[str, Any]:
with open(path_to_ipynb, "r") as f:
with open(path_to_ipynb) as f:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -93,7 +93,7 @@ def test_cli_with_json_output(dir_with_venv_installed):

# assert that there is json output
subprocess.run(shlex.split("poetry run deptry . -o deptry.json"), capture_output=True, text=True)
with open("deptry.json", "r") as f:
with open("deptry.json") as f:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -8,7 +8,7 @@ def test_simple(tmp_path):
with run_within_dir(tmp_path):
JsonWriter(json_output="output.json").write(issues={"one": "two", "three": "four"})

with open("output.json", "r") as f:
with open("output.json") as f:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2022

Codecov Report

Merging #174 (a4d21cf) into main (210a5c0) will not change coverage.
The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #174   +/-   ##
=====================================
  Coverage   95.1%   95.1%           
=====================================
  Files         28      28           
  Lines        895     895           
  Branches     136     136           
=====================================
  Hits         852     852           
  Misses        28      28           
  Partials      15      15           
Impacted Files Coverage Δ
deptry/cli_defaults.py 100.0% <ø> (ø)
deptry/dependency_getter/requirements_txt.py 96.1% <100.0%> (ø)
deptry/notebook_import_extractor.py 100.0% <100.0%> (ø)
deptry/python_file_finder.py 100.0% <100.0%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mkniewallner mkniewallner merged commit 6c9ceff into fpgmaas:main Nov 7, 2022
@mkniewallner mkniewallner deleted the chore/add-pyupgrade branch November 7, 2022 07:21
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.

3 participants