-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
unsafe ANN autofix seems to ignore return in for loop #9269
Labels
bug
Something isn't working
Comments
Thanks! Will take a look. |
Will be fixed in the next release. |
The same issue happens here with if/else: https://github.com/pandas-dev/pandas/blob/b0c2e45997e8f164a181ce8e896dfb414e3eb60c/pandas/util/__init__.py#L1 ruff thinks |
Yeah all the same bug. I overlooked an interaction when I implemented the NoReturn. |
charliermarsh
added a commit
that referenced
this issue
Dec 29, 2023
## Summary Given: ```python from somewhere import get_cfg def lookup_cfg(cfg_description): cfg = get_cfg(cfg_description) if cfg is not None: return cfg raise AttributeError(f"No cfg found matching {cfg_description}") ``` We were analyzing the method from last-to-first statement. So we saw the `raise`, then assumed the method _always_ raised. In reality, though, it _might_ return. This PR improves the branch analysis to respect these mixed cases. Closes #9269. Closes #9304.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ruff --select "ANN001,ANN2" --fix-only
(version 0.1.9) on the following code snippet seems to ignore the return statement in the for loophttps://github.com/pandas-dev/pandas/blob/b0c2e45997e8f164a181ce8e896dfb414e3eb60c/pandas/_version.py#L120
The text was updated successfully, but these errors were encountered: