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

Added support for @type_check_only decorator. This addresses #5810. #5817

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

erictraut
Copy link
Collaborator

No description provided.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

dd-trace-py (https://github.com/DataDog/dd-trace-py): typechecking got 1.33x faster (72.1s -> 54.3s)
(Performance measurements are based on a single noisy sample)

@erictraut erictraut merged commit 6060964 into main Aug 26, 2023
@erictraut erictraut deleted the issue5810 branch August 26, 2023 05:29
tsibley added a commit to nextstrain/cli that referenced this pull request Aug 30, 2023
pyright 1.1.325 (released yesterday) added support for @type_check_only
decorators¹, which were added (a year ago) to the builtins.ellipsis type
of the stdlib typeshed².  This type is available only during
type-checking and doesn't actually exist at runtime, but previously
pyright didn't care about that (and mypy still doesn't).  Now it does,
noticed thanks to scheduled CI, and throws an error like:

    "ellipsis" is marked as @type_check_only and can be used only in
    type annotations (reportGeneralTypeIssues)

Explicitly clarify to pyright that our variable is a type alias³ and not
a value also used at runtime so it knows its ok to use the type of
Ellipsis (via a forward reference to the now-you-see-it, now-you-don't
builtins.ellipsis).

Relatedly, we can switch from 'builtins.ellipsis' → types.EllipsisType
on Python ≥3.10⁴ and stop using the private/internal type for Ellipsis.
I'll do that in the subsequent commit.

¹ <microsoft/pyright#5817>

² <python/typeshed@a92da58>
  <python/typeshed#8531>

³ <https://docs.python.org/3/library/typing.html#typing.TypeAlias>
  <https://peps.python.org/pep-0613/>

⁴ <https://docs.python.org/3/library/types.html#types.EllipsisType>
  <python/cpython#85976>
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