seddonym / import-linter

Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.
https://import-linter.readthedocs.io/
BSD 2-Clause "Simplified" License
664 stars 45 forks source link

Fix: error when using click 6.0 and 7.0 #191

Closed piglei closed 1 year ago

piglei commented 1 year ago

When using import-linter with click~=6.0 or ~=7.0, below error will occour:

❯ lint-imports
Traceback (most recent call last):
  File "lint-imports", line 8, in <module>
    sys.exit(lint_imports_command())

... omited ...

  File "lib/python3.8/site-packages/click/core.py", line 1405, in type_cast_value
    raise TypeError('Attempted to invoke composite type '
TypeError: Attempted to invoke composite type but nargs has been set to 0.  This is not supported; nargs needs to be set to a fixed value > 1.

Through some investigation, I found that this error was caused by the default value of the "--contract" option. The value was set to an empty tuple in the current codebase, causing the click library to treat it as a "composite type" and misbehave.

This PR fixes that by changing the default to an empty list.

seddonym commented 1 year ago

Thanks so much for your help!