Skip to content

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

Open
@Krishna2709

Description

@Krishna2709
  • 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions