Skip to content

Fix mypy typing imports #58

@ns-rse

Description

@ns-rse

Currently most of the files fail linting with mypy with messages like the following from the pre-commit hook...

❱ pre-commit run mypy --files tests/conftest.py
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
tests/conftest.py:18: error: Cannot find implementation or library stub for module named "afmslicer.classes"  [import-not-found]
tests/conftest.py:18: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

When running directly though we see...

 ❱ mypy tests/conftest.py
tests/conftest.py:18: error: Skipping analyzing "afmslicer.classes": module is installed, but missing library stubs or py.typed marker  [import-untyped]
tests/conftest.py:18: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tests/conftest.py:70: error: Returning Any from function declared to return "ndarray[Any, dtype[floating[_64Bit]]]"  [no-any-return]
tests/conftest.py:531: error: Missing type parameters for generic type "npt.NDArray"  [type-arg]
tests/conftest.py:534: error: Returning Any from function declared to return "ndarray[Any, dtype[Any]]"  [no-any-return]
tests/conftest.py:541: error: Returning Any from function declared to return "ndarray[Any, dtype[floating[_64Bit]]]"  [no-any-return]
tests/conftest.py:548: error: Returning Any from function declared to return "ndarray[Any, dtype[floating[_64Bit]]]"  [no-any-return]
tests/conftest.py:552: error: Missing type parameters for generic type "npt.NDArray"  [type-arg]
tests/conftest.py:555: error: Returning Any from function declared to return "ndarray[Any, dtype[Any]]"  [no-any-return]
tests/conftest.py:689: error: Returning Any from function declared to return "ndarray[Any, dtype[floating[_64Bit]]]"  [no-any-return]
tests/conftest.py:696: error: Returning Any from function declared to return "ndarray[Any, dtype[signedinteger[_32Bit]]]"  [no-any-return]
...

Adding src/afmslicer/py.typed as suggested helps with this.

It might be a case of modifying the configuration to use no-namespace-packages as the structure is a src/ based one.

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