-
Notifications
You must be signed in to change notification settings - Fork 191
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 ruff version #6614
base: main
Are you sure you want to change the base?
Bump ruff version #6614
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6614 +/- ##
==========================================
+ Coverage 77.51% 77.90% +0.40%
==========================================
Files 560 567 +7
Lines 41444 42147 +703
==========================================
+ Hits 32120 32831 +711
+ Misses 9324 9316 -8 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
b16a1ae
to
a00d50d
Compare
@@ -1,6 +1,7 @@ | |||
from aiida.engine import ToContext, WorkChain | |||
from child import ChildWorkChain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rearrangement is not that great, but whatever.
.github/workflows/ci-code.yml
Outdated
@@ -104,7 +104,7 @@ jobs: | |||
AIIDA_WARN_v3: 1 | |||
# Python 3.12 has a performance regression when running with code coverage | |||
# so run code coverage only for python 3.9. | |||
run: pytest -v tests -m 'not nightly' ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running pytest in verbose mode produces more than 2000 lines of output, which is extremely annoying in Github UI.
@@ -177,7 +177,7 @@ def list_options(self, entry_point: str) -> list: | |||
# ``typing.Union[str, None].__args__`` will return the tuple ``(str, NoneType)``. So to get the real type, | |||
# we simply remove all ``NoneType`` and the remaining type should be the type of the option. | |||
if hasattr(field_info.annotation, '__args__'): | |||
args = list(filter(lambda e: e != type(None), field_info.annotation.__args__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the few changes, I think this is correct, but please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edan-bainglass I think you familiar with this part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way a different result can be achieved is when a custom type overwrites the equal function. That is not the case for NoneType
, so it is ok.
@@ -208,7 +208,7 @@ def _resolve_nested_context(self, key: str) -> tuple[AttributeDict, str]: | |||
# (subclasses of AttributeDict) but after resolution of an Awaitable this will be the value itself | |||
# * assumption: a resolved value is never a plain AttributeDict, on the other hand if a resolved Awaitable | |||
# would be an AttributeDict we can append things to it since the order of tasks is maintained. | |||
if type(ctx) != AttributeDict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttributeDict
is a class inheriting from dict
so the __eq__
function of the type is not overwritten so it is okay here
e36d075
to
ece43c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to wait until #6630 is merged to fix the CI. Otherwise looks good to me
- id: ruff | ||
exclude: *exclude_ruff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you know what this did?
@@ -177,7 +177,7 @@ def list_options(self, entry_point: str) -> list: | |||
# ``typing.Union[str, None].__args__`` will return the tuple ``(str, NoneType)``. So to get the real type, | |||
# we simply remove all ``NoneType`` and the remaining type should be the type of the option. | |||
if hasattr(field_info.annotation, '__args__'): | |||
args = list(filter(lambda e: e != type(None), field_info.annotation.__args__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way a different result can be achieved is when a custom type overwrites the equal function. That is not the case for NoneType
, so it is ok.
@@ -208,7 +208,7 @@ def _resolve_nested_context(self, key: str) -> tuple[AttributeDict, str]: | |||
# (subclasses of AttributeDict) but after resolution of an Awaitable this will be the value itself | |||
# * assumption: a resolved value is never a plain AttributeDict, on the other hand if a resolved Awaitable | |||
# would be an AttributeDict we can append things to it since the order of tasks is maintained. | |||
if type(ctx) != AttributeDict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttributeDict
is a class inheriting from dict
so the __eq__
function of the type is not overwritten so it is okay here
Most of the changes here are minor import sorting changes (I checked all of them and they all look more correct than before).
The only other change were couple type-comparison (E721) fixes, these should be reviewed carefully.
I also turned off verbose pytest output in CI since it produces thousands of lines and is very difficult to navigate in Github UI.
type-comparison (E721)
Derived from the pycodestyle linter.
What it does
Checks for object type comparisons using
==
and other comparisonoperators.
Why is this bad?
Unlike a direct type comparison,
isinstance
will also check if an objectis an instance of a class or a subclass thereof.
If you want to check for an exact type match, use
is
oris not
.Known problems
When using libraries that override the
==
(__eq__
) operator (such as NumPy,Pandas, and SQLAlchemy), this rule may produce false positives, as converting
from
==
tois
oris not
will change the behavior of the code.For example, the following operations are not equivalent:
Example
Use instead: