[med-svn] [Git][python-team/packages/mypy][master] 4 commits: routine-update: New upstream version
Michael R. Crusoe (@crusoe)
gitlab at salsa.debian.org
Mon Oct 21 09:08:11 BST 2024
Michael R. Crusoe pushed to branch master at Debian Python Team / packages / mypy
Commits:
842a27d6 by Michael R. Crusoe at 2024-10-21T08:48:21+02:00
routine-update: New upstream version
- - - - -
cbe0ee6a by Michael R. Crusoe at 2024-10-21T08:48:22+02:00
New upstream version 1.12.1
- - - - -
05375602 by Michael R. Crusoe at 2024-10-21T08:48:43+02:00
Update upstream source from tag 'upstream/1.12.1'
Update to upstream version '1.12.1'
with Debian dir 495084df9836335eb6508ddcc20ded32a851f8bf
- - - - -
02315826 by Michael R. Crusoe at 2024-10-21T08:49:08+02:00
routine-update: Ready to upload to unstable
- - - - -
13 changed files:
- PKG-INFO
- debian/changelog
- mypy.egg-info/PKG-INFO
- mypy/checker.py
- mypy/checkexpr.py
- mypy/checkmember.py
- mypy/checkpattern.py
- mypy/semanal.py
- mypy/typeshed/stdlib/posixpath.pyi
- mypy/version.py
- test-data/unit/check-recursive-types.test
- test-data/unit/check-selftype.test
- test-data/unit/check-typevar-defaults.test
Changes:
=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: mypy
-Version: 1.12.0
+Version: 1.12.1
Summary: Optional static typing for Python
Home-page: https://www.mypy-lang.org/
Author: Jukka Lehtosalo
=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+mypy (1.12.1-1) unstable; urgency=medium
+
+ * New upstream version
+
+ -- Michael R. Crusoe <crusoe at debian.org> Mon, 21 Oct 2024 08:49:07 +0200
+
mypy (1.12.0-1) unstable; urgency=medium
* New upstream version supports Python 3.13. Closes: #1081617
=====================================
mypy.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: mypy
-Version: 1.12.0
+Version: 1.12.1
Summary: Optional static typing for Python
Home-page: https://www.mypy-lang.org/
Author: Jukka Lehtosalo
=====================================
mypy/checker.py
=====================================
@@ -7520,10 +7520,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
name,
typ,
TempNode(AnyType(TypeOfAny.special_form)),
- False,
- False,
- False,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=typ,
chk=self,
# This is not a real attribute lookup so don't mess with deferring nodes.
=====================================
mypy/checkexpr.py
=====================================
@@ -396,8 +396,8 @@ class ExpressionChecker(ExpressionVisitor[Type]):
# TODO: always do this in type_object_type by passing the original context
result.ret_type.line = e.line
result.ret_type.column = e.column
- if isinstance(get_proper_type(self.type_context[-1]), TypeType):
- # This is the type in a Type[] expression, so substitute type
+ if is_type_type_context(self.type_context[-1]):
+ # This is the type in a type[] expression, so substitute type
# variables with Any.
result = erasetype.erase_typevars(result)
elif isinstance(node, MypyFile):
@@ -1497,10 +1497,10 @@ class ExpressionChecker(ExpressionVisitor[Type]):
member,
typ,
e,
- False,
- False,
- False,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=object_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
@@ -3293,10 +3293,10 @@ class ExpressionChecker(ExpressionVisitor[Type]):
e.name,
original_type,
e,
- is_lvalue,
- False,
- False,
- self.msg,
+ is_lvalue=is_lvalue,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=original_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
@@ -3317,10 +3317,10 @@ class ExpressionChecker(ExpressionVisitor[Type]):
member,
base_type,
context,
- False,
- False,
- False,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=base_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
@@ -3800,11 +3800,12 @@ class ExpressionChecker(ExpressionVisitor[Type]):
method,
base_type,
context,
- False,
- False,
- True,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=True,
+ msg=self.msg,
original_type=original_type,
+ self_type=base_type,
chk=self.chk,
in_literal_context=self.is_literal_context(),
)
@@ -6591,3 +6592,12 @@ def get_partial_instance_type(t: Type | None) -> PartialType | None:
if t is None or not isinstance(t, PartialType) or t.type is None:
return None
return t
+
+
+def is_type_type_context(context: Type | None) -> bool:
+ context = get_proper_type(context)
+ if isinstance(context, TypeType):
+ return True
+ if isinstance(context, UnionType):
+ return any(is_type_type_context(item) for item in context.items)
+ return False
=====================================
mypy/checkmember.py
=====================================
@@ -87,6 +87,7 @@ class MemberContext:
def __init__(
self,
+ *,
is_lvalue: bool,
is_super: bool,
is_operator: bool,
@@ -126,16 +127,16 @@ class MemberContext:
original_type: Type | None = None,
) -> MemberContext:
mx = MemberContext(
- self.is_lvalue,
- self.is_super,
- self.is_operator,
- self.original_type,
- self.context,
- self.msg,
- self.chk,
- self.self_type,
- self.module_symbol_table,
- self.no_deferral,
+ is_lvalue=self.is_lvalue,
+ is_super=self.is_super,
+ is_operator=self.is_operator,
+ original_type=self.original_type,
+ context=self.context,
+ msg=self.msg,
+ chk=self.chk,
+ self_type=self.self_type,
+ module_symbol_table=self.module_symbol_table,
+ no_deferral=self.no_deferral,
)
if messages is not None:
mx.msg = messages
@@ -152,11 +153,11 @@ def analyze_member_access(
name: str,
typ: Type,
context: Context,
+ *,
is_lvalue: bool,
is_super: bool,
is_operator: bool,
msg: MessageBuilder,
- *,
original_type: Type,
chk: mypy.checker.TypeChecker,
override_info: TypeInfo | None = None,
@@ -190,12 +191,12 @@ def analyze_member_access(
are not available via the type object directly)
"""
mx = MemberContext(
- is_lvalue,
- is_super,
- is_operator,
- original_type,
- context,
- msg,
+ is_lvalue=is_lvalue,
+ is_super=is_super,
+ is_operator=is_operator,
+ original_type=original_type,
+ context=context,
+ msg=msg,
chk=chk,
self_type=self_type,
module_symbol_table=module_symbol_table,
=====================================
mypy/checkpattern.py
=====================================
@@ -594,10 +594,10 @@ class PatternChecker(PatternVisitor[PatternType]):
"__match_args__",
typ,
o,
- False,
- False,
- False,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=typ,
chk=self.chk,
)
@@ -660,10 +660,10 @@ class PatternChecker(PatternVisitor[PatternType]):
keyword,
narrowed_type,
pattern,
- False,
- False,
- False,
- self.msg,
+ is_lvalue=False,
+ is_super=False,
+ is_operator=False,
+ msg=self.msg,
original_type=new_type,
chk=self.chk,
)
=====================================
mypy/semanal.py
=====================================
@@ -3958,8 +3958,10 @@ class SemanticAnalyzer(
# so we need to replace it with non-explicit Anys.
res = make_any_non_explicit(res)
if self.options.disallow_any_unimported and has_any_from_unimported_type(res):
- self.msg.unimported_type_becomes_any("Type alias target", res, s)
- res = make_any_non_unimported(res)
+ # Only show error message once, when the type is fully analyzed.
+ if not has_placeholder(res):
+ self.msg.unimported_type_becomes_any("Type alias target", res, s)
+ res = make_any_non_unimported(res)
# Note: with the new (lazy) type alias representation we only need to set no_args to True
# if the expected number of arguments is non-zero, so that aliases like `A = List` work
# but not aliases like `A = TypeAliasType("A", List)` as these need explicit type params.
@@ -4013,6 +4015,8 @@ class SemanticAnalyzer(
existing.node.alias_tvars = alias_tvars
existing.node.no_args = no_args
updated = True
+ # Invalidate recursive status cache in case it was previously set.
+ existing.node._is_recursive = None
else:
# Otherwise just replace existing placeholder with type alias.
existing.node = alias_node
=====================================
mypy/typeshed/stdlib/posixpath.pyi
=====================================
@@ -77,7 +77,11 @@ pathsep: LiteralString
defpath: LiteralString
devnull: LiteralString
-def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
+# Overloads are necessary to work around python/mypy#17952 & python/mypy#11880
+ at overload
+def abspath(path: PathLike[AnyStr]) -> AnyStr: ...
+ at overload
+def abspath(path: AnyStr) -> AnyStr: ...
@overload
def basename(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
@@ -86,8 +90,14 @@ def basename(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
def dirname(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
def dirname(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
-def expanduser(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
-def expandvars(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
+ at overload
+def expanduser(path: PathLike[AnyStr]) -> AnyStr: ...
+ at overload
+def expanduser(path: AnyStr) -> AnyStr: ...
+ at overload
+def expandvars(path: PathLike[AnyStr]) -> AnyStr: ...
+ at overload
+def expandvars(path: AnyStr) -> AnyStr: ...
@overload
def normcase(s: PathLike[AnyStr]) -> AnyStr: ...
@overload
=====================================
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.12.0"
+__version__ = "1.12.1"
base_version = __version__
mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
=====================================
test-data/unit/check-recursive-types.test
=====================================
@@ -1006,3 +1006,11 @@ ta: Tuple[A]
p: Proto
p = ta
[builtins fixtures/tuple.pyi]
+
+[case testRecursiveAliasesWithAnyUnimported]
+# flags: --disallow-any-unimported
+from typing import Callable
+from bogus import Foo # type: ignore
+
+A = Callable[[Foo, "B"], Foo] # E: Type alias target becomes "Callable[[Any, B], Any]" due to an unfollowed import
+B = Callable[[Foo, A], Foo] # E: Type alias target becomes "Callable[[Any, A], Any]" due to an unfollowed import
=====================================
test-data/unit/check-selftype.test
=====================================
@@ -2160,3 +2160,19 @@ class MyProtocol(Protocol):
def test() -> None: ...
value: MyProtocol = test
+
+[case testSelfTypeUnionIter]
+from typing import Self, Iterator, Generic, TypeVar, Union
+
+T = TypeVar("T")
+
+class range(Generic[T]):
+ def __iter__(self) -> Self: ...
+ def __next__(self) -> T: ...
+
+class count:
+ def __iter__(self) -> Iterator[int]: ...
+
+def foo(x: Union[range[int], count]) -> None:
+ for item in x:
+ reveal_type(item) # N: Revealed type is "builtins.int"
=====================================
test-data/unit/check-typevar-defaults.test
=====================================
@@ -717,3 +717,15 @@ def func_d3(
reveal_type(c) # N: Revealed type is "__main__.B[__main__.A[builtins.dict[builtins.int, builtins.float]]]"
reveal_type(d) # N: Revealed type is "__main__.B[builtins.int]"
[builtins fixtures/dict.pyi]
+
+[case testTypeVarDefaultsAndTypeObjectTypeInUnion]
+from __future__ import annotations
+from typing import Generic
+from typing_extensions import TypeVar
+
+_I = TypeVar("_I", default=int)
+
+class C(Generic[_I]): pass
+
+t: type[C] | int = C
+[builtins fixtures/tuple.pyi]
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/compare/ce3eb35c1d131f1cbfd5a8583075ee983635085b...02315826fba76ef56e32dd1ceda8afa8169a41e0
--
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/compare/ce3eb35c1d131f1cbfd5a8583075ee983635085b...02315826fba76ef56e32dd1ceda8afa8169a41e0
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/20241021/591e9ff2/attachment-0001.htm>
More information about the debian-med-commit
mailing list