From a2eb418221477fc245991dbef4047f7c0a84a1f6 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 19 May 2025 18:51:06 -0700 Subject: [PATCH] Modified `generics_type_erasure.py` test to not require an error when accessing a generic attribute on a class when a subtype could provide specialization for that generic attribute. Pyright recently made a modification to eliminate a false positive error in this case. See https://github.com/microsoft/pyright/discussions/10303 for details. I don't think the conformance test should mandate an error in this case. The spec certainly doesn't say anything about it, and the error is potentially a false positive. --- conformance/results/mypy/generics_type_erasure.toml | 1 - conformance/results/mypy/version.toml | 2 +- conformance/results/pyre/generics_type_erasure.toml | 1 - conformance/results/pyre/version.toml | 2 +- conformance/results/pyright/generics_type_erasure.toml | 8 ++------ conformance/results/pytype/generics_type_erasure.toml | 1 - conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 10 +++++----- conformance/tests/generics_type_erasure.py | 2 +- 9 files changed, 11 insertions(+), 18 deletions(-) diff --git a/conformance/results/mypy/generics_type_erasure.toml b/conformance/results/mypy/generics_type_erasure.toml index 46c739fee..e31956bc1 100644 --- a/conformance/results/mypy/generics_type_erasure.toml +++ b/conformance/results/mypy/generics_type_erasure.toml @@ -15,7 +15,6 @@ generics_type_erasure.py:45: error: Access to generic instance variables via cla """ conformance_automated = "Fail" errors_diff = """ -Line 46: Expected 1 errors Line 19: Unexpected errors ['generics_type_erasure.py:19: error: Expression is of type "Node[Never]", not "Node[Any]" [assert-type]'] Line 22: Unexpected errors ['generics_type_erasure.py:22: error: Expression is of type "Never", not "Any" [assert-type]'] """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index b3982776b..04a88f8bf 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.15.0" -test_duration = 1.8 +test_duration = 1.6 diff --git a/conformance/results/pyre/generics_type_erasure.toml b/conformance/results/pyre/generics_type_erasure.toml index af4f56c41..62cdcc8f1 100644 --- a/conformance/results/pyre/generics_type_erasure.toml +++ b/conformance/results/pyre/generics_type_erasure.toml @@ -20,7 +20,6 @@ Line 42: Expected 1 errors Line 43: Expected 1 errors Line 44: Expected 1 errors Line 45: Expected 1 errors -Line 46: Expected 1 errors Line 17: Unexpected errors ["generics_type_erasure.py:17:0 Assert type [70]: Expected `Node[str]` but got `Node[typing_extensions.Literal['']]`."] Line 18: Unexpected errors ['generics_type_erasure.py:18:0 Assert type [70]: Expected `Node[int]` but got `Node[typing_extensions.Literal[0]]`.'] Line 19: Unexpected errors ['generics_type_erasure.py:19:0 Assert type [70]: Expected `Node[typing.Any]` but got `Node[Variable[T]]`.'] diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index cd0a5eb7e..6221116b0 100644 --- a/conformance/results/pyre/version.toml +++ b/conformance/results/pyre/version.toml @@ -1,2 +1,2 @@ version = "pyre 0.9.23" -test_duration = 9.8 +test_duration = 10.4 diff --git a/conformance/results/pyright/generics_type_erasure.toml b/conformance/results/pyright/generics_type_erasure.toml index 0cddc4876..40dfcc911 100644 --- a/conformance/results/pyright/generics_type_erasure.toml +++ b/conformance/results/pyright/generics_type_erasure.toml @@ -1,7 +1,4 @@ -conformant = "Partial" -notes = """ -Missing error regarding `type(instance).generic_attribute`. -""" +conformant = "Pass" output = """ generics_type_erasure.py:38:16 - error: Argument of type "Literal['']" cannot be assigned to parameter "label" of type "int | None" in function "__init__"   Type "Literal['']" is not assignable to type "int | None" @@ -16,7 +13,6 @@ generics_type_erasure.py:43:11 - error: Access to generic instance variable thro generics_type_erasure.py:44:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) generics_type_erasure.py:45:6 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues) """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 46: Expected 1 errors """ diff --git a/conformance/results/pytype/generics_type_erasure.toml b/conformance/results/pytype/generics_type_erasure.toml index ac5e34ce1..e99ed5aee 100644 --- a/conformance/results/pytype/generics_type_erasure.toml +++ b/conformance/results/pytype/generics_type_erasure.toml @@ -10,5 +10,4 @@ Line 42: Expected 1 errors Line 43: Expected 1 errors Line 44: Expected 1 errors Line 45: Expected 1 errors -Line 46: Expected 1 errors """ diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index 22d96d6b1..f8295fb06 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2024.10.11" -test_duration = 33.6 +test_duration = 36.2 diff --git a/conformance/results/results.html b/conformance/results/results.html index c36fa49aa..e20a92f79 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -159,16 +159,16 @@

Python Type System Conformance Test Results

- + @@ -491,7 +491,7 @@

Python Type System Conformance Test Results

- + diff --git a/conformance/tests/generics_type_erasure.py b/conformance/tests/generics_type_erasure.py index c7462259a..b78f29249 100644 --- a/conformance/tests/generics_type_erasure.py +++ b/conformance/tests/generics_type_erasure.py @@ -43,7 +43,7 @@ def __init__(self, label: T | None = None) -> None: Node[int].label # E Node.label = 1 # E Node.label # E -type(n1).label # E +type(n1).label # E? assert_type(n1.label, int) assert_type(Node[int]().label, int) n1.label = 1 # OK pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy

 
mypy 1.15.0
-
1.8sec
+
1.6sec
pyright 1.1.400
1.1sec
pyre 0.9.23
-
9.8sec
+
10.4sec
pytype 2024.10.11
-
33.6sec
+
36.2sec
@@ -356,7 +356,7 @@

Python Type System Conformance Test Results

     generics_type_erasure
Partial

Infers Node[Never] instead of Node[Any] when argument is not provided.

False negative on instance attribute access on type(node).

Partial

no error for `type(n1).label`

Pass
Partial

Does not erase unspecified type variables to `Any` prior to `assert_type` handling.

False negatives on instance attribute access on the type.

Does not infer type of `DefaultDict` with explicit type parameters on constructor.

False negatives on assert_type uses.

Unsupported
     aliases_typealiastype
Partial

Incorrectly rejects some recursive type aliases using TypeAliasType.

Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.

Partial

incorrectly allows undefined self reference

Partial

Incorrectly allows undefined self reference.

Unsupported

Support for TypeAliasType is not implemented.

Unsupported

Support for TypeAliasType is not implemented.