isort
isort copied to clipboard
src_path glob patterns do not work from command line flag
Running isort --src '*/src/' .
results in
Traceback (most recent call last):
File "/Users/pgorniak/.pyenv/versions/3.8.13/bin/isort", line 8, in <module>
sys.exit(main())
File "/Users/pgorniak/.pyenv/versions/3.8.13/lib/python3.8/site-packages/isort/main.py", line 1110, in main
config = Config(**config_dict)
File "/Users/pgorniak/.pyenv/versions/3.8.13/lib/python3.8/site-packages/isort/settings.py", line 470, in __init__
for path in full_paths:
File "/Users/pgorniak/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 1136, in glob
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
File "/Users/pgorniak/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 75, in parse_parts
drv, root, rel = self.splitroot(part)
File "/Users/pgorniak/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 294, in splitroot
if part and part[0] == sep:
TypeError: 'PosixPath' object is not subscriptable
I think because paths are resolved first using pathlib at https://github.com/PyCQA/isort/blob/main/isort/main.py#L1117.
If run via isort .
but with a config file entry like
[settings]
src_paths=*/src/
the pattern works fine because the src_paths
entry doesn't exist yet at the line above and is only read from the config file later, meaning it remains a string and the glob works fine.