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

Enable currently-ignored linting rules E721, E722, F403 #573

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Aug 19, 2024

All three of these are discussed on PEP8 and should not be ignored.

E722 is https://realpython.com/the-most-diabolical-python-antipattern

[tool.ruff.lint]
ignore = [
-  # TODO: remove ignores below this line
-  # comparison syntax in tests
-  "E721",
-  # bare except
-  "E722",
-  # unable to detect undefined names
-  "F403",
]

Copy link

github-actions bot commented Aug 19, 2024

Binder 👈 Launch a binder notebook on this branch for commit 8e6a220

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 75b2f08

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 65.07%. Comparing base (118d49a) to head (75b2f08).
Report is 36 commits behind head on development.

Files with missing lines Patch % Lines
icepyx/quest/quest.py 0.00% 2 Missing ⚠️
icepyx/quest/dataset_scripts/argo.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           development     #573   +/-   ##
============================================
  Coverage        65.07%   65.07%           
============================================
  Files               36       36           
  Lines             3052     3052           
  Branches           538      538           
============================================
  Hits              1986     1986           
  Misses             981      981           
  Partials            85       85           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

assert exp_key in obs.keys()
assert type(obs[exp_key]) == exp_type
assert isinstance(obs[exp_key], exp_type)
Copy link
Member

Choose a reason for hiding this comment

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

Note: this is a test so we have automatic confirmation it's fine, but for anyone not aware, there is a difference in behavior between type(...) == ... and isintance(..., ...) - isinstance evaluates True with inheritance:

>>> class Foo(str):
...     ...
... 
>>> type(Foo()) is str
False
>>> type(Foo()) is Foo
True
>>> isinstance(Foo(), str)
True
>>> isinstance(Foo(), Foo)
True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The == --> is transition would be good enough to silence this ruff rule. The "comparing types" thing is frowned on in PEP8 and there is a different ruff rule that covers that.

Copy link
Member

@mfisher87 mfisher87 Aug 19, 2024

Choose a reason for hiding this comment

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

The more I think about it, the more I think we should go back to exact type comparison with type(...) is .... Since this is a test, loosening the comparison enables the underlying code to change more without breaking the test. We an always come back to this. My little mind is just thinking about the "foolish consistency" part of PEP8.

Would you mind?

@mfisher87 mfisher87 changed the title Remove ruff.lint.ignore=E721,E722,F403 Enable currently-ignored linting rules E721, E722, F403 Aug 19, 2024
@mfisher87
Copy link
Member

Awesome, thank you!

Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

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

Apologies for all the mind-changing I'm doing today @cclauss. Could you address this before merge? https://github.com/icesat2py/icepyx/pull/573/files#r1722071874

Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

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

Lovely! Thank you again 🙇

@mfisher87 mfisher87 merged commit 687766d into icesat2py:development Aug 19, 2024
5 of 6 checks passed
@cclauss cclauss deleted the remove-ruff-ignores branch August 21, 2024 08:06
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