thoth-station / common

A common library for the Thoth project
https://thoth-station.github.io/
GNU General Public License v3.0
4 stars 19 forks source link

`mypy` tests not passing #1252

Closed xtuchyna closed 2 years ago

xtuchyna commented 2 years ago

Describe the bug Related to #1250

To Reproduce Steps to reproduce the behavior:

  1. checkout the branch from PR ( fix/update-pre-commit )
  2. pipenv install --dev
  3. pipenv shell
  4. pre-commit run --all-files
  5. See errors

Expected behavior At least installed type modules should help, but installing them seems to resolve no error

LOGS

thoth/common/openshift.py:374:9: error: Returning Any from function declared to return "Optional[str]"  [no-any-return]
thoth/common/openshift.py:495:9: error: Returning Any from function declared to return "str"  [no-any-return]
thoth/common/workflows.py:22:1: error: Library stubs not installed for "yaml" (or incompatible with Python 3.8)  [import]
thoth/common/workflows.py:180:51: error: Argument 1 to "OpenShift" has incompatible type "**Mapping[str, str]"; expected "bool"  [arg-type]
thoth/common/workflows.py:180:51: error: Argument 1 to "OpenShift" has incompatible type "**Mapping[str, str]"; expected "Optional[Dict[str, str]]"  [arg-type]
thoth/common/logging.py:247: error: Unused "type: ignore" comment
thoth/common/logging.py:284:9: error: Incompatible types in assignment (expression has type "str", variable has type "Union[Logger, PlaceHolder]")  [assignment]
thoth/common/config/base.py:25:1: error: Library stubs not installed for "attr" (or incompatible with Python 3.8)  [import]
thoth/common/config/base.py:25:1: note: Hint: "python3 -m pip install types-attrs"
thoth/common/config/base.py:25:1: note: (or run "mypy --install-types" to install all missing stub packages)
thoth/common/config/base.py:25:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
thoth/common/config/base.py:53: error: Unused "type: ignore" comment
thoth/common/config/base.py:64:9: error: Returning Any from function declared to return "Dict[str, Union[str, int, None]]"  [no-any-return]
thoth/common/config/hardware_information.py:20:1: error: Library stubs not installed for "attr" (or incompatible with Python 3.8)  [import]
thoth/common/config/operating_system.py:20:1: error: Library stubs not installed for "attr" (or incompatible with Python 3.8)  [import]
thoth/common/config/runtime_environment.py:28:1: error: Library stubs not installed for "attr" (or incompatible with Python 3.8)  [import]
thoth/common/config/runtime_environment.py:29:1: error: Library stubs not installed for "yaml" (or incompatible with Python 3.8)  [import]
thoth/common/config/runtime_environment.py:29:1: note: Hint: "python3 -m pip install types-PyYAML"
thoth/common/config/runtime_environment.py:102: error: Unused "type: ignore" comment
thoth/common/config/runtime_environment.py:121: error: Unused "type: ignore" comment
thoth/common/config/runtime_environment.py:131:13: error: Returning Any from function declared to return "Dict[str, Any]"  [no-any-return]
Found 17 errors in 7 files (checked 13 source files)
xtuchyna commented 2 years ago

When trying to downgrade mypy to 0.800 (as it was previously set) and running pre-commit tests:

thoth/common/logging.py:324:30: error: Argument "integrations" to "init" has incompatible type "List[object]"; expected "Sequence[Integration]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "bool"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "int"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "Optional[str]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "List[str]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "Union[Transport, Type[Transport], Callable[[Dict[str, Any]], None], None]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "List[Union[type, str]]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "str"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "Optional[Callable[[Dict[str, Any], Dict[str, Any]], Optional[Dict[str, Any]]]]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "Optional[Callable[[Dict[str, Any]], Union[Real, bool]]]"  [arg-type]
thoth/common/logging.py:326:19: error: Argument 5 to "init" has incompatible type "**Dict[str, float]"; expected "Experiments"  [arg-type]
Found 11 errors in 1 file (checked 13 source files)
sesheta commented 2 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

goern commented 2 years ago

/sig user-experience

xtuchyna commented 2 years ago

@harshad16 we actually removed mypy temporarily here but never patched it back to the pre-commit configuration

harshad16 commented 2 years ago

Good catch thanks for fixing and working on it. :pray:

goern commented 2 years ago

/remove-lifecycle stale