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

Pre-commit broken on seed isort #194

Closed
fmassa opened this issue Jan 26, 2022 · 6 comments · Fixed by #201
Closed

Pre-commit broken on seed isort #194

fmassa opened this issue Jan 26, 2022 · 6 comments · Fixed by #201
Assignees

Comments

@fmassa
Copy link
Contributor

fmassa commented Jan 26, 2022

🐛 Bug

I just enabled the pre-commit hooks in my environment following the docs, and they seem to raise an error in an unrelated part of the codebase.

This is the error message I get after a git commit:

Trim Trailing Whitespace.................................................Passed
Check python ast.........................................................Passed
Check for merge conflicts................................................Passed
Don't commit to branch...................................................Passed
Check for added large files..............................................Passed
Fix End of Files.........................................................Passed
black....................................................................Passed
flake8...................................................................Passed
seed isort known_third_party.............................................Failed
- hook id: seed-isort-config
- exit code: 1

Traceback (most recent call last):
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/bin/seed-isort-config", line 8, in <module>
    sys.exit(main())
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/seed_isort_config.py", line 112, in main
    third_party = third_party_imports(filenames, appdirs)
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/seed_isort_config.py", line 60, in third_party_imports
    visitor.visit(ast.parse(f.read(), filename=filename))
  File "/private/home/fmassa/.conda/envs/xformers/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/private/home/fmassa/.conda/envs/xformers/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/private/home/fmassa/.conda/envs/xformers/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/seed_isort_config.py", line 42, in visit_Import
    self._maybe_append_name(name.name)
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/seed_isort_config.py", line 35, in _maybe_append_name
    imp_type = classify_import(name, self.appdirs)
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/aspy/refactor_imports/classify.py", line 135, in classify_import
    found, module_path, is_builtin = _get_module_info(
  File "/private/home/fmassa/.cache/pre-commit/repohjnsozm1/py_env-python3/lib/python3.8/site-packages/aspy/refactor_imports/classify.py", line 103, in _get_module_info
    assert spec.submodule_search_locations is not None
AssertionError

isort....................................................................Passed
mypy.....................................................................Passed
@blefaudeux
Copy link
Contributor

oh interesting, I don't think that I've ever seen that one :/ looks like something which broke upstream

@blefaudeux
Copy link
Contributor

could you test on a newer python, like 3.9 ? Looks like it could be related to importlib, although this is all new to me

@xwhan
Copy link

xwhan commented Jan 31, 2022

I got the same error when using pre-commit :)

@blefaudeux
Copy link
Contributor

looks like we're not the only ones (see). Maybe that we could remove that step and trust black for all the import ordering for instance ? I did not have much time to look into this, sorry about that

@blefaudeux blefaudeux self-assigned this Feb 2, 2022
@blefaudeux
Copy link
Contributor

ah wait, it's not isort directly but this 'seed isort' step, looking into that and fixing this

@blefaudeux
Copy link
Contributor

ok, depends on this which is deprecated

xwhan pushed a commit to xwhan/xformers that referenced this issue Feb 8, 2022
* pull residual out into factory
* mypy fix
authored-by: Diana Liskovich <dianaml@devfair0471.h2.fair>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants