Update typeddicts_class_syntax.py test to use a custom metaclass. - #2327
Open
rchen152 wants to merge 1 commit into
Open
Update typeddicts_class_syntax.py test to use a custom metaclass.#2327rchen152 wants to merge 1 commit into
rchen152 wants to merge 1 commit into
Conversation
The TypedDict chapter of the spec says: > It is also invalid to specify a custom metaclass. It looks like most type checkers interpret this to mean that the appearance of `metaclass=...` is illegal in a TypedDict definition. Pyrefly interprets this to mean that a non-`type` metaclass is illegal, so a redundant `metaclass=type` is fine. IMO either interpretation is defensible, but the conformance test currently uses `metaclass=type`, which only accommodates the first. This PR changes the test to use a non-`type` metaclass, which is unambiguously an error. This doesn't actually change pyrefly's conformance results because pyrefly has a bug that causes it to emit a different, nonsensical error on the `metaclass=type` line, which was mistakenly taken as pyrefly passing the test. I'm in the process of fixing that bug, which is how I discovered that pyrefly behaves slightly differently from the other checkers here.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TypedDict chapter of the spec says (emphasis mine):
It looks like most type checkers interpret this to mean that the appearance of
metaclass=...is illegal in a TypedDict definition.Pyrefly interprets this to mean that a non-
typemetaclass is illegal, so a redundantmetaclass=typeis fine.IMO either interpretation is defensible, but the conformance test currently uses
metaclass=type, which only accommodates the first. This PR changes the test to use a non-typemetaclass, which is unambiguously an error.This doesn't actually change pyrefly's conformance results because pyrefly has a bug that causes it to emit a different, nonsensical error on the
metaclass=typeline, which was mistakenly taken as pyrefly passing the test. I'm in the process of fixing that bug, which is how I discovered that pyrefly behaves slightly differently from the other checkers here.