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 fails with TypeError #1475

Closed
kbehlers opened this issue Sep 10, 2020 · 3 comments
Closed

pre-commit fails with TypeError #1475

kbehlers opened this issue Sep 10, 2020 · 3 comments

Comments

@kbehlers
Copy link

When I attempt to run the pre-commit command, I get a TypeError.

If I modify this line

DEPRECATED_SETTINGS = ("not_skip", "keep_direct_and_as_imports")

# DEPRECATED_SETTINGS = ("not_skip", "keep_direct_and_as_imports")
DEPRECATED_SETTINGS = ("not_skip", "keep_direct_and_as_imports", "apply")

then the command works.

So it seems somewhere along the line the combined_config from /isort/settings.py is picking up the deprecated --apply flag and passing it.

python3.8
pre-commit==2.7.1

# .pre-commit-config.yaml
default_language_version:
    python: python3.8
repos:
  - repo: https://github.com/pycqa/isort
    rev: '5.5.2'
    hooks:
      - id: isort
Traceback (most recent call last):
  File "/Users/k/.cache/pre-commit/repoccvi_m_m/py_env-python3.8/bin/isort", line 8, in <module>
    sys.exit(main())
  File "/Users/k/.cache/pre-commit/repoccvi_m_m/py_env-python3.8/lib/python3.8/site-packages/isort/main.py", line 830, in main
    config = Config(**config_dict)
  File "/Users/k/.cache/pre-commit/repoccvi_m_m/py_env-python3.8/lib/python3.8/site-packages/isort/settings.py", line 426, in __init__
    super().__init__(sources=tuple(sources), **combined_config)  # type: ignore
TypeError: __init__() got an unexpected keyword argument 'apply'
@kbehlers kbehlers changed the title pre-commit fails with pre-commit fails with TypeError Sep 10, 2020
@timothycrosley
Copy link
Member

@kbehlers, Thanks for reporting this issue!

This error just means you have a config file lying around somewhere in your project with apply=true or similar, which is not a supported setting nor has ever been within config files. 4.x.x would simply ignore these errors, whereas isort 5 bubbles them up. If you remove this config option the error should go away without a change to the isort code.

@kbehlers
Copy link
Author

@timothycrosley Thank you for clearing that up for me, and pointing me in the right direction! That was 100% the problem, and I finally found the setting hanging out in setup.cfg.

@timothycrosley
Copy link
Member

Glad that worked! Your issue did highlight how confusing the current error behaviour was so I've updated that in develop which will make it's way out in the next release: #1476

Thanks!

~Timothy

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

No branches or pull requests

2 participants