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

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Mon Oct 30 20:33:08 GMT 2023



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


Commits:
3e7d282f by Michael R. Crusoe at 2023-10-30T20:21:27+01:00
New upstream version 1.6.1
- - - - -


6 changed files:

- PKG-INFO
- mypy.egg-info/PKG-INFO
- mypy/expandtype.py
- mypy/types.py
- mypy/version.py
- test-data/unit/check-parameter-specification.test


Changes:

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


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


=====================================
mypy/expandtype.py
=====================================
@@ -236,7 +236,7 @@ class ExpandTypeVisitor(TrivialSyntheticTypeTranslator):
             return repl.copy_modified(
                 flavor=t.flavor,
                 prefix=t.prefix.copy_modified(
-                    arg_types=self.expand_types(t.prefix.arg_types + repl.prefix.arg_types),
+                    arg_types=self.expand_types(t.prefix.arg_types) + repl.prefix.arg_types,
                     arg_kinds=t.prefix.arg_kinds + repl.prefix.arg_kinds,
                     arg_names=t.prefix.arg_names + repl.prefix.arg_names,
                 ),
@@ -244,7 +244,7 @@ class ExpandTypeVisitor(TrivialSyntheticTypeTranslator):
         elif isinstance(repl, Parameters):
             assert t.flavor == ParamSpecFlavor.BARE
             return Parameters(
-                self.expand_types(t.prefix.arg_types + repl.arg_types),
+                self.expand_types(t.prefix.arg_types) + repl.arg_types,
                 t.prefix.arg_kinds + repl.arg_kinds,
                 t.prefix.arg_names + repl.arg_names,
                 variables=[*t.prefix.variables, *repl.variables],
@@ -327,12 +327,14 @@ class ExpandTypeVisitor(TrivialSyntheticTypeTranslator):
             # the replacement is ignored.
             if isinstance(repl, Parameters):
                 # We need to expand both the types in the prefix and the ParamSpec itself
-                t = t.expand_param_spec(repl)
                 return t.copy_modified(
-                    arg_types=self.expand_types(t.arg_types),
+                    arg_types=self.expand_types(t.arg_types[:-2]) + repl.arg_types,
+                    arg_kinds=t.arg_kinds[:-2] + repl.arg_kinds,
+                    arg_names=t.arg_names[:-2] + repl.arg_names,
                     ret_type=t.ret_type.accept(self),
                     type_guard=(t.type_guard.accept(self) if t.type_guard is not None else None),
                     imprecise_arg_kinds=(t.imprecise_arg_kinds or repl.imprecise_arg_kinds),
+                    variables=[*repl.variables, *t.variables],
                 )
             elif isinstance(repl, ParamSpecType):
                 # We're substituting one ParamSpec for another; this can mean that the prefix
@@ -340,7 +342,8 @@ class ExpandTypeVisitor(TrivialSyntheticTypeTranslator):
                 prefix = repl.prefix
                 clean_repl = repl.copy_modified(prefix=Parameters([], [], []))
                 return t.copy_modified(
-                    arg_types=self.expand_types(t.arg_types[:-2] + prefix.arg_types)
+                    arg_types=self.expand_types(t.arg_types[:-2])
+                    + prefix.arg_types
                     + [
                         clean_repl.with_flavor(ParamSpecFlavor.ARGS),
                         clean_repl.with_flavor(ParamSpecFlavor.KWARGS),


=====================================
mypy/types.py
=====================================
@@ -2068,16 +2068,6 @@ class CallableType(FunctionLike):
         prefix = Parameters(self.arg_types[:-2], self.arg_kinds[:-2], self.arg_names[:-2])
         return arg_type.copy_modified(flavor=ParamSpecFlavor.BARE, prefix=prefix)
 
-    def expand_param_spec(self, c: Parameters) -> CallableType:
-        variables = c.variables
-        return self.copy_modified(
-            arg_types=self.arg_types[:-2] + c.arg_types,
-            arg_kinds=self.arg_kinds[:-2] + c.arg_kinds,
-            arg_names=self.arg_names[:-2] + c.arg_names,
-            is_ellipsis_args=c.is_ellipsis_args,
-            variables=[*variables, *self.variables],
-        )
-
     def with_unpacked_kwargs(self) -> NormalizedCallableType:
         if not self.unpack_kwargs:
             return cast(NormalizedCallableType, self)


=====================================
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.6.0"
+__version__ = "1.6.1"
 base_version = __version__
 
 mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


=====================================
test-data/unit/check-parameter-specification.test
=====================================
@@ -1839,3 +1839,73 @@ g(cb, y=0, x='a')  # OK
 g(cb, y='a', x=0)  # E: Argument "y" to "g" has incompatible type "str"; expected "int" \
                    # E: Argument "x" to "g" has incompatible type "int"; expected "str"
 [builtins fixtures/paramspec.pyi]
+
+[case testParamSpecNoCrashOnUnificationAlias]
+import mod
+[file mod.pyi]
+from typing import Callable, Protocol, TypeVar, overload
+from typing_extensions import ParamSpec
+
+P = ParamSpec("P")
+R_co = TypeVar("R_co", covariant=True)
+Handler = Callable[P, R_co]
+
+class HandlerDecorator(Protocol):
+    def __call__(self, handler: Handler[P, R_co]) -> Handler[P, R_co]: ...
+
+ at overload
+def event(event_handler: Handler[P, R_co]) -> Handler[P, R_co]: ...
+ at overload
+def event(namespace: str, *args, **kwargs) -> HandlerDecorator: ...
+[builtins fixtures/paramspec.pyi]
+
+[case testParamSpecNoCrashOnUnificationCallable]
+import mod
+[file mod.pyi]
+from typing import Callable, Protocol, TypeVar, overload
+from typing_extensions import ParamSpec
+
+P = ParamSpec("P")
+R_co = TypeVar("R_co", covariant=True)
+
+class HandlerDecorator(Protocol):
+    def __call__(self, handler: Callable[P, R_co]) -> Callable[P, R_co]: ...
+
+ at overload
+def event(event_handler: Callable[P, R_co]) -> Callable[P, R_co]: ...
+ at overload
+def event(namespace: str, *args, **kwargs) -> HandlerDecorator: ...
+[builtins fixtures/paramspec.pyi]
+
+[case testParamSpecNoCrashOnUnificationPrefix]
+from typing import Any, Callable, TypeVar, overload
+from typing_extensions import ParamSpec, Concatenate
+
+T = TypeVar("T")
+U = TypeVar("U")
+V = TypeVar("V")
+W = TypeVar("W")
+P = ParamSpec("P")
+
+ at overload
+def call(
+    func: Callable[Concatenate[T, P], U],
+    x: T,
+    *args: Any,
+    **kwargs: Any,
+) -> U: ...
+ at overload
+def call(
+    func: Callable[Concatenate[T, U, P], V],
+    x: T,
+    y: U,
+    *args: Any,
+    **kwargs: Any,
+) -> V: ...
+def call(*args: Any, **kwargs: Any) -> Any: ...
+
+def test1(x: int) -> str: ...
+def test2(x: int, y: int) -> str: ...
+reveal_type(call(test1, 1))  # N: Revealed type is "builtins.str"
+reveal_type(call(test2, 1, 2))  # N: Revealed type is "builtins.str"
+[builtins fixtures/paramspec.pyi]



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

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/commit/3e7d282f4007f2a3dfc6776cbd6f1b006b5cdb1a
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/20231030/0b01935a/attachment-0001.htm>


More information about the debian-med-commit mailing list