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

src_path glob patterns do not work from command line flag #2001

Open
sumpfork opened this issue Nov 17, 2022 · 0 comments · May be fixed by #2284
Open

src_path glob patterns do not work from command line flag #2001

sumpfork opened this issue Nov 17, 2022 · 0 comments · May be fixed by #2284
Assignees
Labels
bug Something isn't working

Comments

@sumpfork
Copy link

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.

@anirudnits anirudnits added the bug Something isn't working label Mar 22, 2023
@anirudnits anirudnits self-assigned this Mar 22, 2023
@marcelo-souzaf marcelo-souzaf linked a pull request Aug 4, 2024 that will close this issue
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