[med-svn] [Git][python-team/packages/mypy][upstream] New upstream version 1.0.1

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Sun Feb 26 08:25:39 GMT 2023



Michael R. Crusoe pushed to branch upstream at Debian Python Team / packages / mypy


Commits:
4a6df570 by Michael R. Crusoe at 2023-02-24T09:07:33+01:00
New upstream version 1.0.1
- - - - -


13 changed files:

- PKG-INFO
- mypy.egg-info/PKG-INFO
- mypy/fixup.py
- mypy/nodes.py
- mypy/partially_defined.py
- mypy/traverser.py
- mypy/types.py
- mypy/version.py
- mypyc/test-data/irbuild-i64.test
- test-data/unit/check-incremental.test
- test-data/unit/check-python310.test
- test-data/unit/check-python38.test
- test-data/unit/check-typevar-values.test


Changes:

=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: mypy
-Version: 1.0.0
+Version: 1.0.1
 Summary: Optional static typing for Python
 Home-page: http://www.mypy-lang.org/
 Author: Jukka Lehtosalo


=====================================
mypy.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: mypy
-Version: 1.0.0
+Version: 1.0.1
 Summary: Optional static typing for Python
 Home-page: http://www.mypy-lang.org/
 Author: Jukka Lehtosalo


=====================================
mypy/fixup.py
=====================================
@@ -80,9 +80,13 @@ class NodeFixer(NodeVisitor[None]):
             if info.tuple_type:
                 info.tuple_type.accept(self.type_fixer)
                 info.update_tuple_type(info.tuple_type)
+                if info.special_alias:
+                    info.special_alias.alias_tvars = list(info.defn.type_vars)
             if info.typeddict_type:
                 info.typeddict_type.accept(self.type_fixer)
                 info.update_typeddict_type(info.typeddict_type)
+                if info.special_alias:
+                    info.special_alias.alias_tvars = list(info.defn.type_vars)
             if info.declared_metaclass:
                 info.declared_metaclass.accept(self.type_fixer)
             if info.metaclass_type:


=====================================
mypy/nodes.py
=====================================
@@ -3473,8 +3473,13 @@ class TypeAlias(SymbolNode):
 
     @classmethod
     def from_tuple_type(cls, info: TypeInfo) -> TypeAlias:
-        """Generate an alias to the tuple type described by a given TypeInfo."""
+        """Generate an alias to the tuple type described by a given TypeInfo.
+
+        NOTE: this doesn't set type alias type variables (for generic tuple types),
+        they must be set by the caller (when fully analyzed).
+        """
         assert info.tuple_type
+        # TODO: is it possible to refactor this to set the correct type vars here?
         return TypeAlias(
             info.tuple_type.copy_modified(fallback=mypy.types.Instance(info, info.defn.type_vars)),
             info.fullname,
@@ -3484,8 +3489,13 @@ class TypeAlias(SymbolNode):
 
     @classmethod
     def from_typeddict_type(cls, info: TypeInfo) -> TypeAlias:
-        """Generate an alias to the TypedDict type described by a given TypeInfo."""
+        """Generate an alias to the TypedDict type described by a given TypeInfo.
+
+        NOTE: this doesn't set type alias type variables (for generic TypedDicts),
+        they must be set by the caller (when fully analyzed).
+        """
         assert info.typeddict_type
+        # TODO: is it possible to refactor this to set the correct type vars here?
         return TypeAlias(
             info.typeddict_type.copy_modified(
                 fallback=mypy.types.Instance(info, info.defn.type_vars)


=====================================
mypy/partially_defined.py
=====================================
@@ -396,8 +396,8 @@ class PossiblyUndefinedVariableVisitor(ExtendedTraverserVisitor):
         self.tracker.end_branch_statement()
 
     def visit_match_stmt(self, o: MatchStmt) -> None:
-        self.tracker.start_branch_statement()
         o.subject.accept(self)
+        self.tracker.start_branch_statement()
         for i in range(len(o.patterns)):
             pattern = o.patterns[i]
             pattern.accept(self)


=====================================
mypy/traverser.py
=====================================
@@ -253,9 +253,9 @@ class TraverserVisitor(NodeVisitor[None]):
             o.expr.accept(self)
 
     def visit_call_expr(self, o: CallExpr) -> None:
+        o.callee.accept(self)
         for a in o.args:
             a.accept(self)
-        o.callee.accept(self)
         if o.analyzed:
             o.analyzed.accept(self)
 


=====================================
mypy/types.py
=====================================
@@ -587,12 +587,16 @@ class TypeVarType(TypeVarLikeType):
         return visitor.visit_type_var(self)
 
     def __hash__(self) -> int:
-        return hash((self.id, self.upper_bound))
+        return hash((self.id, self.upper_bound, tuple(self.values)))
 
     def __eq__(self, other: object) -> bool:
         if not isinstance(other, TypeVarType):
             return NotImplemented
-        return self.id == other.id and self.upper_bound == other.upper_bound
+        return (
+            self.id == other.id
+            and self.upper_bound == other.upper_bound
+            and self.values == other.values
+        )
 
     def serialize(self) -> JsonDict:
         assert not self.id.is_meta_var()


=====================================
mypy/version.py
=====================================
@@ -8,7 +8,7 @@ from mypy import git
 # - Release versions have the form "1.2.3".
 # - Dev versions have the form "1.2.3+dev" (PLUS sign to conform to PEP 440).
 # - Before 1.0 we had the form "0.NNN".
-__version__ = "1.0.0"
+__version__ = "1.0.1"
 base_version = __version__
 
 mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


=====================================
mypyc/test-data/irbuild-i64.test
=====================================
@@ -1731,7 +1731,7 @@ def f5():
 L0:
     return 4
 
-[case testI64Cast]
+[case testI64Cast_64bit]
 from typing import cast
 from mypy_extensions import i64
 
@@ -1772,6 +1772,39 @@ L2:
 L3:
     return r3
 
+[case testI64Cast_32bit]
+from typing import cast
+from mypy_extensions import i64
+
+def cast_int(x: int) -> i64:
+    return cast(i64, x)
+[out]
+def cast_int(x):
+    x :: int
+    r0 :: native_int
+    r1 :: bit
+    r2, r3, r4 :: int64
+    r5 :: ptr
+    r6 :: c_ptr
+    r7 :: int64
+L0:
+    r0 = x & 1
+    r1 = r0 == 0
+    if r1 goto L1 else goto L2 :: bool
+L1:
+    r2 = extend signed x: builtins.int to int64
+    r3 = r2 >> 1
+    r4 = r3
+    goto L3
+L2:
+    r5 = x ^ 1
+    r6 = r5
+    r7 = CPyLong_AsInt64(r6)
+    r4 = r7
+    keep_alive x
+L3:
+    return r4
+
 [case testI64ExplicitConversionFromVariousTypes]
 from mypy_extensions import i64
 


=====================================
test-data/unit/check-incremental.test
=====================================
@@ -6359,3 +6359,34 @@ from m import Foo
 [file m.py]
 from missing_module import Meta  # type: ignore[import]
 class Foo(metaclass=Meta): ...
+
+[case testGenericTypedDictWithError]
+import b
+[file a.py]
+from typing import Generic, TypeVar
+from typing_extensions import TypedDict
+
+TValue = TypeVar("TValue")
+class Dict(TypedDict, Generic[TValue]):
+    value: TValue
+
+[file b.py]
+from a import Dict, TValue
+
+def f(d: Dict[TValue]) -> TValue:
+    return d["value"]
+def g(d: Dict[TValue]) -> TValue:
+    return d["x"]
+
+[file b.py.2]
+from a import Dict, TValue
+
+def f(d: Dict[TValue]) -> TValue:
+    return d["value"]
+def g(d: Dict[TValue]) -> TValue:
+    return d["y"]
+[builtins fixtures/dict.pyi]
+[out]
+tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "x"
+[out2]
+tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "y"


=====================================
test-data/unit/check-python310.test
=====================================
@@ -1813,6 +1813,19 @@ def f1(x: int) -> int:
 
 [typing fixtures/typing-medium.pyi]
 
+[case testUsedBeforeDefMatchWalrus]
+# flags: --enable-error-code used-before-def
+import typing
+
+def f0(x: int) -> None:
+    a = y  # E: Cannot determine type of "y"  # E: Name "y" is used before definition
+    match y := x:
+        case 1:
+            b = y
+        case 2:
+            c = y
+    d = y
+
 [case testTypeAliasWithNewUnionSyntaxAndNoneLeftOperand]
 from typing import overload
 class C:


=====================================
test-data/unit/check-python38.test
=====================================
@@ -573,6 +573,14 @@ def foo() -> None:
     [x := x + y for y in [1, 2, 3]]
 [builtins fixtures/dict.pyi]
 
+[case testWalrusUsedBeforeDef]
+# flags: --python-version 3.8
+class C:
+    def f(self, c: 'C') -> None: pass
+
+(x := C()).f(y)  # E: Cannot determine type of "y"  # E: Name "y" is used before definition
+(y := C()).f(y)
+
 [case testOverloadWithPositionalOnlySelf]
 # flags: --python-version 3.8
 from typing import overload, Optional


=====================================
test-data/unit/check-typevar-values.test
=====================================
@@ -702,3 +702,12 @@ class Indexable:
 
 [builtins fixtures/tuple.pyi]
 [builtins fixtures/classmethod.pyi]
+
+[case testTypeVarWithValueDeferral]
+from typing import TypeVar, Callable
+
+T = TypeVar("T", "A", "B")
+Func = Callable[[], T]
+
+class A: ...
+class B: ...



View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/commit/4a6df5708f18da324c53055d2d56d581ca0501e2

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/commit/4a6df5708f18da324c53055d2d56d581ca0501e2
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230226/1aad18fb/attachment-0001.htm>


More information about the debian-med-commit mailing list