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

Template run.py uses typing but fails mypy #52

Closed
deepyaman opened this issue Jul 9, 2019 · 2 comments
Closed

Template run.py uses typing but fails mypy #52

deepyaman opened this issue Jul 9, 2019 · 2 comments
Labels
Issue: Bug Report 🐞 Bug that needs to be fixed

Comments

@deepyaman
Copy link
Member

deepyaman commented Jul 9, 2019

Description

There are typing issues in template run.py; e.g. runner is typed as a str but later used as a Runner.

Some of the issues may just require bypassing (e.g. Pathlib / operator).

Context

I'm trying to check typing in my project.

Steps to Reproduce

  1. Create a new kedro project.
  2. Install mypy.
  3. Run mypy. My mypy.ini:
[mypy]
new_semantic_analyzer = True

[mypy-kedro.*,nbstripout,numpy,pandas,pytest,scipy.*]
ignore_missing_imports = True

Expected Result

No errors.

Actual Result

I have to add:

[mypy-cotopaxi.run]
ignore_errors = True

to mypy.ini, else:

(project-cotopaxi) BOS-178551-C02X31K9JHD4:project-cotopaxi deepyaman$ mypy src/cotopaxi src/tests kedro_cli.py 
src/cotopaxi/run.py:80: error: Incompatible types in assignment (expression has type "Path", variable has type "str")
src/cotopaxi/run.py:83: error: Unsupported left operand type for / ("str")
src/cotopaxi/run.py:84: error: Unsupported left operand type for / ("str")
src/cotopaxi/run.py:147: error: "str" not callable
src/cotopaxi/run.py:147: error: "None" not callable

Your Environment

Include as many relevant details about the environment in which you experienced the bug:

  • Kedro version used (pip show kedro or kedro -V): 0.13.1.dev53 🤣
  • Python version used (python -V): 3.7.3
  • Operating system and version:
@deepyaman deepyaman added the Issue: Bug Report 🐞 Bug that needs to be fixed label Jul 9, 2019
@tolomea
Copy link
Contributor

tolomea commented Jul 10, 2019

We recommend enabling the mypy flag --allow-redefinition and we use it internally and it will probably become the default in a future mypy version.
https://mypy.readthedocs.io/en/latest/common_issues.html#redefinitions-with-incompatible-types
https://mypy.readthedocs.io/en/latest/command_line.html?highlight=redefinition#miscellaneous-strictness-flags

Does that resolve your issue?

On a larger note we are considering options around linting the template to prevent issues with things like mypy.

@deepyaman
Copy link
Member Author

@tolomea That works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Bug Report 🐞 Bug that needs to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants