-
-
Notifications
You must be signed in to change notification settings - Fork 45
Disable typing in py/private/pytest.py.tmpl
#577
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
Disable typing in py/private/pytest.py.tmpl
#577
Conversation
Ignore typing in generated code. This fixes a regression that occurred after upgrading to the latest version of the rules. There, our tooling started producing the following typing errors. ``` bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:35: error: Cannot find implementation or library stub for module named "coverage" [import-not-found] bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:35: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:37: error: Argument 1 to "open" has incompatible type "str | None"; expected "int | str | bytes | PathLike[str] | PathLike[bytes]" [arg-type] bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:78: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc" [arg-type] bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:84: error: Argument 1 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]" [arg-type] bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:109: error: Unsupported left operand type for + ("None") [operator] bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:109: note: Left operand is of type "str | None" bazel-out/k8-fastbuild/bin/packages/cmk-agent-based/__test__.py:114: error: Argument 1 to "open" has incompatible type "str | None"; expected "int | str | bytes | PathLike[str] | PathLike[bytes]" [arg-type] Found 6 errors in 1 file (checked 1 source file) ``` Related: * aspect-build#428
|
Thanks for the contribution, my take is that #570 is a better approach since it allows us to provide more verification of the base code we're delivering and opens the door to removing the need for a template action in the normal cases. |
Yes, indeed. In the long-term, it's certainly be better to type and lint the file instead of silencing the type checker. I'd nevertheless propose the following, pragmatic approach:
|
Not my favorite but I agree it's incrementally less broken. Let's take it for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Disable type checking in generated code.
This fixes a regression that occurred after upgrading to the latest version of the rules. There, our tooling started producing the following typing errors.
Related:
Changes are visible to end-users: yes
This patch fixes a regression.