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

Precommit mypy increment #729

Closed
wants to merge 5 commits into from
Closed

Conversation

MattWellie
Copy link
Contributor

Down to 119 mypy failures

@MattWellie MattWellie requested a review from jmarshall May 7, 2024 01:30
@jmarshall
Copy link
Contributor

jmarshall commented May 7, 2024

I can't review this without explanations of why you're making the changes you're making. In particular:

  • Replacing instances of cpg_utils's Path by (pathlib.Path, CloudPath) seems like a backwards step. What is the reason for it?

  • Adding # type: ignore annotations should be an absolute last resort IMHO. What errors are being reported in these various instances, and why can we not reasonably refactor them away?

@MattWellie
Copy link
Contributor Author

  1. See Unexpected error behaviour: Parameterized generics cannot be used with class or instance checks python/mypy#12155, error: Parameterized generics cannot be used with class or instance checks - mypy (rightly or wrongly) doesn't support using our Path (a union of CloudPath | pathlib.Path) in isinstance checks
  2. Most of the type: ignore statements are around Hail ResourceGroups - there's no way I can see to solve error: Value of type "Resource" is not indexable for named ResourceGroups, Hail does some job-creation-time magic to swap out job.output['vcf.gz'] for a filepath, and the entity job.[arbitrary_name] can't really have a fixed type.

Other instances of the latter are around expected_outputs - when returning a dict[str, str | Path], mypy fails with incompatible type on all usage of the contents unless the expected type of each is literally str | Path. We could pull out each value individually and assert a specific type, but... there's 120 more errors to address and only so many hours in the day.

@jmarshall
Copy link
Contributor

jmarshall commented May 7, 2024

As you say, there are a lot of such instances, and it would not make development any more fun if we have to annotate our new code similarly.

I think we should look at selectively disabling some type checking (e.g. perhaps saying that whatever returns the expect_outputs returns them as Any; or nixing this plan to expose cpg_utils to mypy) before carrying on down this road of putting ignore directives everywhere.

@MattWellie MattWellie closed this May 7, 2024
@MattWellie MattWellie deleted the precommit-mypy_increment branch October 11, 2024 04:01
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