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

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Wed Jun 8 13:59:40 BST 2022



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


Commits:
dd57bba0 by Michael R. Crusoe at 2022-06-06T21:28:31+02:00
New upstream version 0.961
- - - - -


8 changed files:

- PKG-INFO
- mypy.egg-info/PKG-INFO
- mypy/semanal.py
- mypy/semanal_main.py
- mypy/version.py
- test-data/unit/check-attr.test
- test-data/unit/check-dataclasses.test
- test-data/unit/fine-grained.test


Changes:

=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: mypy
-Version: 0.960
+Version: 0.961
 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: 0.960
+Version: 0.961
 Summary: Optional static typing for Python
 Home-page: http://www.mypy-lang.org/
 Author: Jukka Lehtosalo


=====================================
mypy/semanal.py
=====================================
@@ -4505,7 +4505,9 @@ class SemanticAnalyzer(NodeVisitor[None],
         """
         # TODO: Forward reference to name imported in class body is not
         #       caught.
-        assert self.statement  # we are at class scope
+        if self.statement is None:
+            # Assume it's fine -- don't have enough context to check
+            return True
         return (node is None
                 or self.is_textually_before_statement(node)
                 or not self.is_defined_in_current_module(node.fullname)


=====================================
mypy/semanal_main.py
=====================================
@@ -82,10 +82,10 @@ def semantic_analysis_for_scc(graph: 'Graph', scc: List[str], errors: Errors) ->
     # We use patch callbacks to fix up things when we expect relatively few
     # callbacks to be required.
     apply_semantic_analyzer_patches(patches)
-    # This pass might need fallbacks calculated above.
-    check_type_arguments(graph, scc, errors)
     # Run class decorator hooks (they requite complete MROs and no placeholders).
     apply_class_plugin_hooks(graph, scc, errors)
+    # This pass might need fallbacks calculated above and the results of hooks.
+    check_type_arguments(graph, scc, errors)
     calculate_class_properties(graph, scc, errors)
     check_blockers(graph, scc)
     # Clean-up builtins, so that TypeVar etc. are not accessible without importing.
@@ -133,10 +133,9 @@ def semantic_analysis_for_targets(
         process_top_level_function(analyzer, state, state.id,
                                    n.node.fullname, n.node, n.active_typeinfo, patches)
     apply_semantic_analyzer_patches(patches)
-
+    apply_class_plugin_hooks(graph, [state.id], state.manager.errors)
     check_type_arguments_in_targets(nodes, state, state.manager.errors)
     calculate_class_properties(graph, [state.id], state.manager.errors)
-    apply_class_plugin_hooks(graph, [state.id], state.manager.errors)
 
 
 def restore_saved_attrs(saved_attrs: SavedAttributes) -> None:


=====================================
mypy/version.py
=====================================
@@ -5,7 +5,7 @@ from mypy import git
 # - Release versions have the form "0.NNN".
 # - Dev versions have the form "0.NNN+dev" (PLUS sign to conform to PEP 440).
 # - For 1.0 we'll switch back to 1.2.3 form.
-__version__ = '0.960'
+__version__ = '0.961'
 base_version = __version__
 
 mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


=====================================
test-data/unit/check-attr.test
=====================================
@@ -1734,3 +1734,18 @@ class C:
         # E: Unsupported converter, only named functions and types are currently supported
     )
 [builtins fixtures/dict.pyi]
+
+[case testAttrsNestedClass]
+from typing import List
+import attr
+
+ at attr.s
+class C:
+    @attr.s
+    class D:
+        pass
+    x = attr.ib(type=List[D])
+
+c = C(x=[C.D()])
+reveal_type(c.x)  # N: Revealed type is "builtins.list[__main__.C.D]"
+[builtins fixtures/list.pyi]


=====================================
test-data/unit/check-dataclasses.test
=====================================
@@ -1772,3 +1772,21 @@ c = C()
 c2 = C(x=1)
 c.x  # E: "C" has no attribute "x"
 [builtins fixtures/dataclasses.pyi]
+
+[case testDataclassCheckTypeVarBounds]
+# flags: --python-version 3.7
+from dataclasses import dataclass
+from typing import Protocol, Dict, TypeVar, Generic
+
+class DataclassProtocol(Protocol):
+    __dataclass_fields__: Dict
+
+T = TypeVar("T", bound=DataclassProtocol)
+
+ at dataclass
+class MyDataclass:
+    x: int = 1
+
+class MyGeneric(Generic[T]): ...
+class MyClass(MyGeneric[MyDataclass]): ...
+[builtins fixtures/dataclasses.pyi]


=====================================
test-data/unit/fine-grained.test
=====================================
@@ -9734,6 +9734,7 @@ class C:
 [out]
 ==
 main:5: error: Unsupported left operand type for + ("str")
+
 [case testNoneAttribute]
 from typing import Generic, TypeVar
 
@@ -9759,3 +9760,30 @@ class ExampleClass(Generic[T]):
         self.example_attribute = None
 [out]
 ==
+
+[case testDataclassCheckTypeVarBoundsInReprocess]
+# flags: --python-version 3.7
+from dataclasses import dataclass
+from typing import Protocol, Dict, TypeVar, Generic
+from m import x
+
+class DataclassProtocol(Protocol):
+    __dataclass_fields__: Dict
+
+T = TypeVar("T", bound=DataclassProtocol)
+
+ at dataclass
+class MyDataclass:
+    x: int = 1
+
+class MyGeneric(Generic[T]): ...
+class MyClass(MyGeneric[MyDataclass]):  ...
+
+[file m.py]
+x: int
+[file m.py.2]
+x: str
+
+[builtins fixtures/dataclasses.pyi]
+[out]
+==



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

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/commit/dd57bba01abdd747a4a807db7f4decbd724c2af0
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/20220608/611f43b2/attachment-0001.htm>


More information about the debian-med-commit mailing list