-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Enable ruff PLW2101,PLW2901,PLW3301 rule #57700
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
base: main
Are you sure you want to change the base?
Conversation
6b58278 to
0eb1c69
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.
PLW2901 seems good to me, I find it to be a source of error and confusion too.
c408eb3 to
0b47076
Compare
| else: | ||
| v = v_in |
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 one is a -0 from me since they arguably not only don’t help, but acually make this kind of operations easier to get wrong.
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.
Hi @uranusjr are you referring to this specific case of serialized objects (where we could exclude with # noqa: ... or is it a general concern?
In rework making the codebase compatible I also had one other point in https://github.com/apache/airflow/pull/57700/files#diff-94532ce5cd8778da565396e51f54f7a10078725a1f61656615fbb173b7503fceR1818 where making code compliant made me a hard time.
So do you mean in these specific cases we should exclude rule where it makes code not better? Or do you dislike the rule in general (I think in 90% of cases it prevents failures).
I can also raise a discussion in devlist if you think we should have a larger round of forming an opinion on the rule.
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.
It’s -0 so I’d not block this, but personally I’m not into this loop variable reuse rule in general.
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 reverted the usage in serialized_objects and made it minimal invasive. Hope this improves to have a 0.000001 instead of -0 :-D
|
the descirption was inaccurate, just updated it. |
airflow-core/src/airflow/api_fastapi/core_api/services/public/variables.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/hooks/athena.py
Outdated
Show resolved
Hide resolved
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.
Wei suggestions are good.
Beside naming the general approach sounds good to me.
0b47076 to
a06cd94
Compare
Thanks @Lee-W for the great feedback! Adjusted names to your very good proposals! |
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.
A few nits. But looks great! Thanks!
| executor_names_per_team = [] | ||
| for name in executor_names_config: | ||
| if len(split_name := name.split(":")) == 1: | ||
| for executor_name_str in executor_names_config: |
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 we need the _str here? ignore me if it's needed 👀
| for executor_name_str in executor_names_config: | |
| for executor_name in executor_names_config: |
| for _, module_name, _ in iter_namespace(airflow.serialization.serializers): | ||
| module = import_module(module_name) | ||
| for serializers in getattr(module, "serializers", ()): | ||
| s = serializers if isinstance(serializers, str) else qualname(serializers) |
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.
| s = serializers if isinstance(serializers, str) else qualname(serializers) | |
| serializers_qualname = serializers if isinstance(serializers, str) else qualname(serializers) |
nit: s or d don't fit my taste. or s_qualname might be better 🤔
| c = qualname(c) | ||
| if c in _deserializers and _deserializers[c] != name: | ||
| raise AttributeError(f"duplicate {c} for stringifiers in {name} and {_stringifiers[c]}") | ||
| for stringifiers in getattr(module, "stringifiers", ()): |
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.
Probably not something we need to do it this PR. but we maybe can duplicate these few for loop 🤔
| for file_path_raw in find_path_from_directory(plugin_folder_path, ignore_list_file, "glob"): | ||
| file_path = Path(file_path_raw) |
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.
| for file_path_raw in find_path_from_directory(plugin_folder_path, ignore_list_file, "glob"): | |
| file_path = Path(file_path_raw) | |
| for raw_file_path in find_path_from_directory(plugin_folder_path, ignore_list_file, "glob"): | |
| file_path = Path(raw_file_path) |
While implementing #57294 I realized that a couple of more ruff PLW rules might be interesting, this PR enables
See also https://docs.astral.sh/ruff/rules/#warning-plw