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

Add types to file generated by __test__.py #428

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

antspy
Copy link
Contributor

@antspy antspy commented Oct 30, 2024

I am adding types to user_args otherwise mypy complains when running bazel test.

I am trying to automatically run mypy when building my bazel targets. I am using rules_mypy for this.
I am also using the py_pytest_main rule:

py_pytest_main(
    name = "__test__",
    deps = ["@pip//pytest"],
)

py_test(
    name = "mytest",
    size = "small",
    srcs = [
        "mytest.py",
        ":__test__",
    ],
    main = ":__test__.py",
    package_collisions = "warning",
    deps = [
        ":__test__",
        ":mylib",
    ],
)

However, if I run bazel test mytest, mypy complains: bazel-out/k8-fastbuild/bin/src/backend2/__test__.py:42: error: Need type annotation for "user_args" (hint: "user_args: list[<type>] = ...") [var-annotated].
I haven't found a way to remove the __test__ file from mypy analysis, and this is actually a simple fix, so I thought we could patch this in.


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: no
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes/no

I am adding types to user_args otherwise mypy complains when running `bazel test`.
@CLAassistant
Copy link

CLAassistant commented Oct 30, 2024

CLA assistant check
All committers have signed the CLA.

@mattem
Copy link
Contributor

mattem commented Nov 8, 2024

Thanks!

@mattem mattem enabled auto-merge (squash) November 8, 2024 20:36
@mattem mattem merged commit 509ed22 into aspect-build:main Nov 8, 2024
1 check passed
mattem added a commit that referenced this pull request Nov 13, 2024
mattem pushed a commit that referenced this pull request Nov 13, 2024
Reverts #428

Revert as it's causing a failure on CI for older versions of Python.
@mattem
Copy link
Contributor

mattem commented Nov 13, 2024

Sorry, this got reverted as it's not compatible with older versions of Python it seems. I didn't notice that CI didn't run on this diff, and it caused main to go red.

I think we should be able to template this file so that we can take the Python version into account when adding type annotations.

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.

3 participants