Open clavedeluna opened 2 years ago
Hi! Is there any further progress?
In the course of working on this feature I've encountered an example which would defy the PEP8 instructions.
This example is actually within isort:
from importlib import metadata
__version__ = metadata.version("isort")
PEP8 says to move version up above the import, but it in fact depends on the import! I'm not sure what the guidance would be here, I can do some research, but I would expect not to change anything in this case. It would be a bit difficult to detect correctly though.
Given the resolution of https://github.com/python/peps/issues/2971#issuecomment-1387178523 I think there are two options here:
I like 2 best for simplicity, but either option is going to require detecting if a dunder assignment relies on an import statement, which may be challenging.
I can see in a related issue #711 dunders were at least prevented from moving. However, according to PEP8, dunders should come after future imports but before the other import block.
This is correct according to PEP8
This is incorrect
But currently isort does not move the dunders. I propose this is implemented to correctly align with PEP8. Related pylint issue https://github.com/PyCQA/pylint/issues/5471