Skip to content

Conversation

yanyongyu
Copy link
Owner

related to #184

@sterliakov
Copy link

This kind of diagnostic:

/home/runner/work/githubkit/githubkit/githubkit/versions/v2022_11_28/webhooks/pull_request.py:67:17 - error: Argument of type "UnionType" cannot be assigned to parameter "type_" of type "type[T@TaggedUnion]" in function "__init__"
  Type "UnionType" is not assignable to type "type[T@TaggedUnion]" (reportArgumentType)
Error: Argument of type "UnionType" cannot be assigned to parameter "type_" of type "type[T@TaggedUnion]" in function "__init__"

can be solved with a # type: ignore (probably preferred, this way it will work at least for "regular" classes passed), a tricky extra overload or Any. The future solution for exactly this kind of problem is TypeForm (PEP-741), but it isn't officially approved and stabilized yet.

Pyright has experimental support for TypeForm (with enableExperimentalFeatures), TypeForm can be imported from typing_extensions. But beware that

enableExperimentalFeatures [boolean]: [...] These features will likely change or be removed, so they should not be used except for experimentation purposes.

@yanyongyu yanyongyu merged commit 689cc1e into master Jan 24, 2025
35 of 37 checks passed
@yanyongyu yanyongyu deleted the ci/pyright branch January 24, 2025 07:04
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