flake8-type-checking: Always recognise relative imports as first-party#12994
flake8-type-checking: Always recognise relative imports as first-party#12994AlexWaygood merged 1 commit intomainfrom
flake8-type-checking: Always recognise relative imports as first-party#12994Conversation
…than a u32 `level` argument
|
|
I guess we can't mark it as internal if it fixes a bug. It's important for users to be aware of this when looking at the changelog |
It felt unlikely that it would actually come up in practice, and the ecosystem report strengthened my supposition there, so I wondered if it was really worth putting it in the changelog... but definitely don't feel strongly |
is_relative argument to isort::categorize, rather than a u32 level argumentflake8-type-checking: Always recognise relative imports as first-party
MichaReiser
left a comment
There was a problem hiding this comment.
I like it.
I would be inclined to even use an enum with a Relative variant to improve readability on the call site but what you have here is good with me too.
A small refactor. The exact number of dots at the beginning of a relative import isnt relevant to the
isortclassification (and never will be). All that matters is whether there are any dots at the beginning or not. Using a boolean here improves readability and makes it clearer what the argument is for when the function is called from other rules elsewhere in Ruff.In the process, this fixes what I believe is a small bug in the
flake8-type-checkingcode, where we're always passinglevel=0into thecategorize()function. I think this means we may be miscategorising some imports there which would otherwise be categorised as first-party imports due to them being relative imports.