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

Incompatible default for argument "cfg_path" (default has type "None", argument has type "Path") #863

Open
Krishna2709 opened this issue Feb 21, 2023 · 1 comment

Comments

@Krishna2709
Copy link

Krishna2709 commented Feb 21, 2023

  • While running tox the mypy classification_model checks fail.
  • Error:
test_package: OK ✔ in 3.99 seconds
checks: commands[0]> flake8 classification_model tests
checks: commands[1]> isort classification_model tests
Fixing C:\Users\krish\titanicSurvival\production-model-package\classification_model\pipeline.py
checks: commands[2]> black classification_model tests
checks: commands[3]> mypy classification_model
classification_model\config\core.py: note: In function "fetch_config_from_yaml":
classification_model\config\core.py:57: error: Incompatible default for argument "cfg_path" (default has type "None", argument has type "Path")  [assignment]
classification_model\config\core.py:57: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
classification_model\config\core.py:57: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
Found 1 error in 1 file (checked 12 source files)
checks: exit 1 (0.50 seconds) C:\Users\krish\titanicSurvival\production-model-package> mypy classification_model pid=28348
  test_package: OK (3.99=setup[0.06]+cmd[1.76,2.16] seconds)
  checks: FAIL code 1 (2.26=setup[0.04]+cmd[0.86,0.28,0.58,0.50] seconds)
  evaluation failed :( (6.78 seconds)
  • Update the [testenv:checks] in tox.ini as following:
[testenv:checks]
envdir = {toxworkdir}/checks
deps =
	-r{toxinidir}/requirements/typing_requirements.txt
commands =
	flake8 classification_model tests
	isort classification_model tests
	black classification_model tests
	{posargs:mypy classification_model --implicit-optional}
  • Note that we added --implicit-optional in the last command: posargs
  • Results:
checks: commands[3]> mypy classification_model --implicit-optional
Success: no issues found in 12 source files
  test_package: OK (3.81=setup[0.09]+cmd[1.72,2.00] seconds)
  checks: OK (3.25=setup[0.02]+cmd[0.81,0.27,0.58,1.58] seconds)
  congratulations :) (7.66 seconds)
@ferygood
Copy link

Thanks @Krishna2709 ! I face the same error and the command --implicit-optional help mypy to pass the type-checking to optional variables which may be missing or have inconsistent types.

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