FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[stubtest] support `@type_check_only` decorator by sobolevn · Pull Request #16422 · python/mypy · GitHub

Repository navigation

[stubtest] support @type_check_only decorator - #16422

Merged
sobolevn merged 5 commits into
masterfrom
issue-15146
Nov 11, 2023
Merged

sobolevn merged 5 commits into
masterfrom
issue-15146

Conversation

sobolevn commented Nov 8, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

There are several TODO items for the future (not this PR):

  • Add an error code to disallow importing things that are decorated with @type_check_only
  • Support @overloaded functions. But, how? There are two options: we can treat individual overload cases as @type_check_only or we can treat the whole func. Since typeshed does not have any examples of this, I prefer to defer this discussion to somewhere else and support this when we decide

Refs #15146

sobolevn requested a review from AlexWaygood November 8, 2023 16:15
Comment thread mypy/test/teststubtest.py Outdated
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not sure I fully understand what the point is of adding the tests you've added in this file, since they all seem to be asserting undesirable behaviour

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It is not undersirable, it just a status-quo. It is expected to be working like this for now. We don't have any other expected behavior for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, and the status quo is undesirable -- ideally, mypy would fully support @type_check_only. If somebody came along and implemented the feature in the future, I think it would be highly confusing if existing tests started failing as a result of the feature being implemented

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ok, we now know that these tests work and can add them later.
I am actually interested in working on this further :)

This comment has been minimized.

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks great, thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we need the changes to the fixtures anymore, after the latest push?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It is typing-full, it won't hurt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sure, makes sense

This comment has been minimized.

Copy link
Copy Markdown
Contributor

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

discord.py (https://github.com/Rapptz/discord.py): typechecking got 1.07x slower (148.4s -> 159.0s)
(Performance measurements are based on a single noisy sample)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL