pip icon indicating copy to clipboard operation
pip copied to clipboard

Apply new repo-review suggestion RF003

Open DimitriPapadopoulos opened this issue 1 year ago • 3 comments

RF003: src directory doesn't need to be specified anymore (0.6+)

Ruff now (0.6+) looks in the src directory by default. The src setting doesn't need to be specified if it's just set to ["src"].

CAVEAT: Removing src = ["src"] results in changes related to the I rules, as suggested by the 0.6.0 release announcement;

By default, our isort rules now search inside src/ directories when determining the list of package names that are likely to represent first-party code. This was always configurable, but it was suprising for many users that Ruff didn't understand this common project structure "out of the box".

This change may result in some of your imports being reordered or recategorised, as import statements that these rules previously considered to be third-party imports will now be correctly understood as first-party.

DimitriPapadopoulos avatar Aug 24 '24 18:08 DimitriPapadopoulos

I tried this myself after seeing the ruff changelog but it produces wrong import sorting, from pip._vendor.* is supposed to be marked as 3rd party as per the config:

known-third-party = ["pip._vendor"]

But this PR moves pip._vendor.* to be first party with pip._internal.*. This is either a bug in ruff or something in the ruff config needs to be updated.

notatallshaw avatar Aug 24 '24 19:08 notatallshaw

Indeed, this doesn't seem right. Pehraps related to https://github.com/astral-sh/ruff/issues/10266.

DimitriPapadopoulos avatar Aug 24 '24 20:08 DimitriPapadopoulos

OP in that issue says known-third-party is a workaround for their issue, but in this example known-third-party is not helping.

It might be the same as this https://github.com/astral-sh/ruff/issues/12984.

notatallshaw avatar Aug 24 '24 20:08 notatallshaw

Thanks for your interest in contributing to pip, however, this can be revisited when the relevant Ruff bug(s) are fixed.

ichard26 avatar Jul 07 '25 21:07 ichard26