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

Gets MyPy pre-commit hook to run on all files. #22

Merged
merged 4 commits into from
Feb 10, 2025

Conversation

jeanluciano
Copy link
Contributor

This PR updates .pre-commit-config.yaml to run on the src directory. It all fixes all current errors in CI.

Copy link

linear bot commented Feb 10, 2025

ENG-1335 Fix mypy issues in precommit hook

We are currently getting the mypy errors below when running the hook on the entire repo.

src/prefect_cloud/utilities/callables.py:41: error: Unexpected argument to "TypeVar()": "infer_variance"  [misc]
src/prefect_cloud/utilities/callables.py:344: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:346: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:367: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:369: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:402: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:404: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/utilities/callables.py:412: error: Incompatible types in assignment (expression has type "list[None]", variable has type "list[expr | None]")  [assignment]
src/prefect_cloud/utilities/callables.py:412: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
src/prefect_cloud/utilities/callables.py:412: note: Consider using "Sequence" instead, which is covariant
src/prefect_cloud/utilities/callables.py:414: error: Unsupported operand types for + ("list[None]" and "list[expr | None]")  [operator]
src/prefect_cloud/utilities/callables.py:449: error: Incompatible types in assignment (expression has type "type[_empty]", variable has type "expr | None")  [assignment]
src/prefect_cloud/schemas/objects.py:138: error: Library stubs not installed for "croniter"  [import-untyped]
src/prefect_cloud/schemas/objects.py:138: note: Hint: "python3 -m pip install types-croniter"
src/prefect_cloud/schemas/objects.py:138: note: (or run "mypy --install-types" to install all missing stub packages)
src/prefect_cloud/schemas/objects.py:138: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
src/prefect_cloud/auth.py:107: error: "Coroutine[Any, Any, tuple[str, str, str]]" object is not iterable  [misc]
src/prefect_cloud/auth.py:109: error: Cannot determine type of "api_url"  [has-type]
src/prefect_cloud/auth.py:110: error: Cannot determine type of "api_key"  [has-type]
src/prefect_cloud/completions.py:34: error: "_AsyncGeneratorContextManager[PrefectCloudClient]" has no attribute "__enter__"  [attr-defined]
src/prefect_cloud/completions.py:34: error: "_AsyncGeneratorContextManager[PrefectCloudClient]" has no attribute "__exit__"; maybe "__aexit__"?  [attr-defined]
src/prefect_cloud/cli.py:169: error: Argument 1 to "exit_with_error" has incompatible type "MissingProfileError"; expected "str"  [arg-type]
src/prefect_cloud/cli.py:304: error: "Coroutine[Any, Any, tuple[str, str, str]]" object is not iterable  [misc]
src/prefect_cloud/cli.py:306: error: Cannot determine type of "ui_url"  [has-type]
src/prefect_cloud/cli.py:308: error: "DeploymentFlowRun" has no attribute "name"  [attr-defined]

Copy link
Contributor

@chrisguidry chrisguidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES

Comment on lines 30 to 33
files: |
(?x)^(
src/prefect_cloud/.*
)$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, could we also do the test suite? Maybe just remove the filter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a lot of noise, we could do that in a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope I like that better.

@jeanluciano jeanluciano merged commit 39909fb into main Feb 10, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants