-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[red-knot] all types are assignable to object #15332
Merged
Merged
Conversation
This file contains 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
carljm
requested review from
MichaReiser,
AlexWaygood and
sharkdp
as code owners
January 7, 2025 21:21
7 tasks
|
AlexWaygood
approved these changes
Jan 7, 2025
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
reviewed
Jan 7, 2025
AlexWaygood
reviewed
Jan 7, 2025
carljm
commented
Jan 7, 2025
AlexWaygood
approved these changes
Jan 7, 2025
dcreager
added a commit
that referenced
this pull request
Jan 8, 2025
* main: [`pylint`] Fix `unreachable` infinite loop (`PLW0101`) (#15278) fix invalid syntax in workflow file (#15357) [`pycodestyle`] Avoid false positives related to type aliases (`E252`) (#15356) [`flake8-builtins`] Disapply `A005` to stub files (#15350) Improve logging system using `logLevel`, avoid trace value (#15232) [`flake8-builtins`] Rename `A005` and improve its error message (#15348) Spruce up docs for pydoclint rules (#15325) [`flake8-type-checking`] Apply `TC008` more eagerly in `TYPE_CHECKING` blocks and disapply it in stubs (#15180) [red-knot] `knot_extensions` Python API (#15103) Display Union of Literals as a Literal (#14993) [red-knot] all types are assignable to object (#15332) [`ruff`] Parenthesize arguments to `int` when removing `int` would change semantics in `unnecessary-cast-to-int` (`RUF046`) (#15277) [`eradicate`] Correctly handle metadata blocks directly followed by normal blocks (`ERA001`) (#15330) Narrowing for class patterns in match statements (#15223) [red-knot] add call checking (#15200) Spruce up docs for `slice-to-remove-prefix-or-suffix` (`FURB188`) (#15328) [`internal`] Return statements in finally block point to end block for `unreachable` (`PLW0101`) (#15276) [`ruff`] Treat `)` as a regex metacharacter (`RUF043`, `RUF055`) (#15318) Use uv consistently throughout the documentation (#15302)
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.
Summary
Type[Any]
should be assignable toobject
. All types should be assignable toobject
.We specifically didn't understand the former; this PR adds a test for it, and a case to ensure that
Type[Any]
is assignable to anything thattype
is assignable to (which includesobject
).This PR also adds a property test that all types are assignable to object. In order to make it pass, I added a special case to check early if we are assigning to
object
and just returntrue
. In principle, once we get all the more general cases correct, this special case might be removable. But having the special case for now allows the property test to pass.And we add a property test that all types are subtypes of object. This failed for the case of an intersection with no positive elements (that is, a negation type). This really does need to be a special case for
object
, because there is no other type we can know that a negation type is a subtype of.Test Plan
Added unit test and property test.