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

N817 not correctly detecting from xml.etree import ElementTree as ET #12940

Closed
lengau opened this issue Aug 16, 2024 · 5 comments · Fixed by #12946
Closed

N817 not correctly detecting from xml.etree import ElementTree as ET #12940

lengau opened this issue Aug 16, 2024 · 5 comments · Fixed by #12946
Assignees
Labels
bug Something isn't working

Comments

@lengau
Copy link
Contributor

lengau commented Aug 16, 2024

In ruff 0.6.1, this file:

from xml.etree import ElementTree as ET

_ = ET

causes N817 to trigger an error with the default ruff settings,even though the default value of lint.flake8-import-conventions contains that mapping and it's supposed to be ignored according to the docs.

$ ruff check --fix --unsafe-fixes --select ICN001,N817 sample.py 
sample.py:2:23: N817 CamelCase `ElementTree` imported as acronym `ET`
  |
2 | from xml.etree import ElementTree as ET
  |                       ^^^^^^^^^^^^^^^^^ N817
3 | 
4 | _ = ET
  |

Found 1 error.
import xml.etree.ElementTree as ET

_ = ET

failed in 0.6.0 but is fixed in 0.6.1

lengau added a commit to canonical/craft-parts that referenced this issue Aug 16, 2024
@MichaReiser
Copy link
Member

Thanks for reporting. This was fixed in 0.6.1. Can you try upgrading?

@lengau
Copy link
Contributor Author

lengau commented Aug 16, 2024

Thanks! I saw the 0.6.1 upgrade after reporting and will do so as soon as my build completes

@lengau
Copy link
Contributor Author

lengau commented Aug 16, 2024

@MichaReiser thanks for the quick turnaround! I've amended the bug report, as the from ... import ... as ... form still fails.

I personally consider it low priority since I've just gone ahead and changed them to import ... as ... and let the auto-fixer fix them :-)

lengau added a commit to canonical/craft-parts that referenced this issue Aug 16, 2024
@lengau lengau changed the title N817 not correctly detecting xml.etree.ElementTree N817 not correctly detecting from xml.etree import ElementTree as ET Aug 16, 2024
@MichaReiser
Copy link
Member

Ohh I see. Thanks for updating the issue and sorry for the oversight

@lengau
Copy link
Contributor Author

lengau commented Aug 17, 2024

That was quick! Thank you!

lengau added a commit to canonical/craft-parts that referenced this issue Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants