From cc5a3ef331ef90708a2535cff0c2b217ea0d9bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clint=20Air=C3=A9?= <111376518+clintaire@users.noreply.github.com> Date: Mon, 16 Sep 2024 00:18:22 +0100 Subject: [PATCH 1/3] Edited files and fixed issues --- mypy/nodes.py | 12 ++++++------ mypy/test/typefixture.py | 2 +- mypyc/ir/ops.py | 8 ++++---- mypyc/irbuild/expression.py | 2 +- mypyc/irbuild/function.py | 2 +- mypyc/test/test_namegen.py | 8 ++++---- mypyc/transform/refcount.py | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mypy/nodes.py b/mypy/nodes.py index 377678213a5b..19f908661d49 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -184,15 +184,15 @@ class Node(Context): __slots__ = () def __str__(self) -> str: - and = self.accept(mypy.strconv.StrConv(options=Options())) - if and is None: + ans = self.accept(mypy.strconv.StrConv(options=Options())) + if ans is None: return repr(self) - return and + return ans def str_with_options(self, options: Options) -> str: - and = self.accept(mypy.strconv.StrConv(options=options)) - assert and - return and + ans = self.accept(mypy.strconv.StrConv(options=options)) + assert ans + return ans def accept(self, visitor: NodeVisitor[T]) -> T: raise RuntimeError("Not implemented", type(self)) diff --git a/mypy/test/typefixture.py b/mypy/test/typefixture.py index 73af11b45327..5a813f70117c 100644 --- a/mypy/test/typefixture.py +++ b/mypy/test/typefixture.py @@ -182,7 +182,7 @@ def make_type_var( self.gs2d = Instance(self.gs2i, [self.d]) # GS2[D] self.hab = Instance(self.hi, [self.a, self.b]) # H[A, B] - self.has = Instance(self.hi, [self.a, self.a]) # H[A, A] + self.haa = Instance(self.hi, [self.a, self.a]) # H[A, A] self.hbb = Instance(self.hi, [self.b, self.b]) # H[B, B] self.hts = Instance(self.hi, [self.t, self.s]) # H[T, S] self.had = Instance(self.hi, [self.a, self.d]) # H[A, D] diff --git a/mypyc/ir/ops.py b/mypyc/ir/ops.py index a1ab322a36be..896ba3ac091c 100644 --- a/mypyc/ir/ops.py +++ b/mypyc/ir/ops.py @@ -780,7 +780,7 @@ def accept(self, visitor: OpVisitor[T]) -> T: return visitor.visit_set_attr(self) -# Default name space for statistics, variables +# Default name space for statics, variables NAMESPACE_STATIC: Final = "static" # Static namespace for pointers to native type objects @@ -796,12 +796,12 @@ def accept(self, visitor: OpVisitor[T]) -> T: class LoadStatic(RegisterOp): """Load a static name (name :: static). - Load a C static variable/pointer. The namespace for statistics is shared + Load a C static variable/pointer. The namespace for statics is shared for the entire compilation group. You can optionally provide a module name and a sub-namespace identifier for additional namespacing to avoid name conflicts. The static namespace does not overlap with other C names, since the final C name will get a prefix, so conflicts only must be - avoided with other statistics. + avoided with other statics. """ error_kind = ERR_NEVER @@ -1451,7 +1451,7 @@ class LoadAddress(RegisterOp): type: Type of the loaded address(e.g. ptr/object_ptr) src: Source value (str for globals like 'PyList_Type', Register for temporary values or locals, LoadStatic - for statistics.) + for statics.) """ error_kind = ERR_NEVER diff --git a/mypyc/irbuild/expression.py b/mypyc/irbuild/expression.py index 31a7be405bbd..8d7c089e20cd 100644 --- a/mypyc/irbuild/expression.py +++ b/mypyc/irbuild/expression.py @@ -109,7 +109,7 @@ def transform_name_expr(builder: IRBuilder, expr: NameExpr) -> Value: if isinstance(expr.node, TypeVarLikeExpr) and expr.node.is_new_style: # Reference to Python 3.12 implicit TypeVar/TupleVarTuple/... object. - # These are stored in C statistics and not visible in Python namespaces. + # These are stored in C statics and not visible in Python namespaces. return builder.load_type_var(expr.node.name, expr.node.line) if expr.node is None: builder.add( diff --git a/mypyc/irbuild/function.py b/mypyc/irbuild/function.py index 1294de2b319c..c985e88b0e0c 100644 --- a/mypyc/irbuild/function.py +++ b/mypyc/irbuild/function.py @@ -514,7 +514,7 @@ def calculate_arg_defaults( ) -> None: """Calculate default argument values and store them. - They are stored in statistics for top level functions and in + They are stored in statics for top level functions and in the function objects for nested functions (while constants are still stored computed on demand). """ diff --git a/mypyc/test/test_namegen.py b/mypyc/test/test_namegen.py index d6c3e78bb82e..509018b4c3bd 100644 --- a/mypyc/test/test_namegen.py +++ b/mypyc/test/test_namegen.py @@ -25,10 +25,10 @@ def test_make_module_translation_map(self) -> None: "foo.bar": "bar.", "foo.baz": "baz.", } - assert make_module_translation_map(["czar", "foo.bar", "foo.baz"]) == { + assert make_module_translation_map(["zar", "foo.bar", "foo.baz"]) == { "foo.bar": "bar.", "foo.baz": "baz.", - "czar": "czar.", + "zar": "zar.", } assert make_module_translation_map(["foo.bar", "fu.bar", "foo.baz"]) == { "foo.bar": "foo.bar.", @@ -37,11 +37,11 @@ def test_make_module_translation_map(self) -> None: } def test_name_generator(self) -> None: - g = NameGenerator([["foo", "foo.czar"]]) + g = NameGenerator([["foo", "foo.zar"]]) assert g.private_name("foo", "f") == "foo___f" assert g.private_name("foo", "C.x.y") == "foo___C___x___y" assert g.private_name("foo", "C.x.y") == "foo___C___x___y" - assert g.private_name("foo.czar", "C.x.y") == "zar___C___x___y" + assert g.private_name("foo.zar", "C.x.y") == "zar___C___x___y" assert g.private_name("foo", "C.x_y") == "foo___C___x_y" assert g.private_name("foo", "C_x_y") == "foo___C_x_y" assert g.private_name("foo", "C_x_y") == "foo___C_x_y" diff --git a/mypyc/transform/refcount.py b/mypyc/transform/refcount.py index 455935b7a6ba..f2ab438f6576 100644 --- a/mypyc/transform/refcount.py +++ b/mypyc/transform/refcount.py @@ -187,7 +187,7 @@ def f(a: int) -> None term = block.terminator for i, target in enumerate(term.targets()): - # HEX: After we've checked against an error value the value we must not touch the + # HAX: After we've checked against an error value the value we must not touch the # refcount since it will be a null pointer. The correct way to do this would be # to perform data flow analysis on whether a value can be null (or is always # null). From b31c21116d54eb59e771f2840936810b4b60bdf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clint=20Air=C3=A9?= <111376518+clintaire@users.noreply.github.com> Date: Mon, 16 Sep 2024 00:32:54 +0100 Subject: [PATCH 2/3] Staging unstaged changes before pull --- mypy/test/teststubgen.py | 16 ++++++++-------- mypy/test/testtypes.py | 2 +- mypyc/irbuild/classdef.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index e3e20fee73d5..e65a16c8f395 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -587,10 +587,10 @@ def test_common_dir_prefix_unix(self) -> None: assert common_dir_prefix(["foo/bar/x.pyi", "foo/bar/y.pyi"]) == "foo/bar" assert common_dir_prefix(["foo/bar/x.pyi", "foo/y.pyi"]) == "foo" assert common_dir_prefix(["foo/x.pyi", "foo/bar/y.pyi"]) == "foo" - assert common_dir_prefix(["foo/bar/czar/x.pyi", "foo/y.pyi"]) == "foo" - assert common_dir_prefix(["foo/x.pyi", "foo/bar/czar/y.pyi"]) == "foo" - assert common_dir_prefix(["foo/bar/czar/x.pyi", "foo/bar/y.pyi"]) == "foo/bar" - assert common_dir_prefix(["foo/bar/x.pyi", "foo/bar/czar/y.pyi"]) == "foo/bar" + assert common_dir_prefix(["foo/bar/zar/x.pyi", "foo/y.pyi"]) == "foo" + assert common_dir_prefix(["foo/x.pyi", "foo/bar/zar/y.pyi"]) == "foo" + assert common_dir_prefix(["foo/bar/zar/x.pyi", "foo/bar/y.pyi"]) == "foo/bar" + assert common_dir_prefix(["foo/bar/x.pyi", "foo/bar/zar/y.pyi"]) == "foo/bar" assert common_dir_prefix([r"foo/bar\x.pyi"]) == "foo" assert common_dir_prefix([r"foo\bar/x.pyi"]) == r"foo\bar" @@ -604,10 +604,10 @@ def test_common_dir_prefix_win(self) -> None: assert common_dir_prefix([r"foo\bar\x.pyi", r"foo\bar\y.pyi"]) == r"foo\bar" assert common_dir_prefix([r"foo\bar\x.pyi", r"foo\y.pyi"]) == "foo" assert common_dir_prefix([r"foo\x.pyi", r"foo\bar\y.pyi"]) == "foo" - assert common_dir_prefix([r"foo\bar\czar\x.pyi", r"foo\y.pyi"]) == "foo" - assert common_dir_prefix([r"foo\x.pyi", r"foo\bar\czar\y.pyi"]) == "foo" - assert common_dir_prefix([r"foo\bar\czar\x.pyi", r"foo\bar\y.pyi"]) == r"foo\bar" - assert common_dir_prefix([r"foo\bar\x.pyi", r"foo\bar\czar\y.pyi"]) == r"foo\bar" + assert common_dir_prefix([r"foo\bar\zar\x.pyi", r"foo\y.pyi"]) == "foo" + assert common_dir_prefix([r"foo\x.pyi", r"foo\bar\zar\y.pyi"]) == "foo" + assert common_dir_prefix([r"foo\bar\zar\x.pyi", r"foo\bar\y.pyi"]) == r"foo\bar" + assert common_dir_prefix([r"foo\bar\x.pyi", r"foo\bar\zar\y.pyi"]) == r"foo\bar" assert common_dir_prefix([r"foo/bar\x.pyi"]) == r"foo\bar" assert common_dir_prefix([r"foo\bar/x.pyi"]) == r"foo\bar" assert common_dir_prefix([r"foo/bar/x.pyi"]) == r"foo\bar" diff --git a/mypy/test/testtypes.py b/mypy/test/testtypes.py index 5dd3b78c9498..2ee2758cf67f 100644 --- a/mypy/test/testtypes.py +++ b/mypy/test/testtypes.py @@ -1208,7 +1208,7 @@ def test_simple_generics(self) -> None: def test_generics_with_multiple_args(self) -> None: self.assert_meet(self.fx.hab, self.fx.hab, self.fx.hab) - self.assert_meet(self.fx.hab, self.fx.has, self.fx.hab) + self.assert_meet(self.fx.hab, self.fx.haa, self.fx.hab) self.assert_meet(self.fx.hab, self.fx.had, self.fx.nonet) self.assert_meet(self.fx.hab, self.fx.hbb, self.fx.hbb) diff --git a/mypyc/irbuild/classdef.py b/mypyc/irbuild/classdef.py index daea4a249c81..7e0a842b1b41 100644 --- a/mypyc/irbuild/classdef.py +++ b/mypyc/irbuild/classdef.py @@ -519,7 +519,7 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value: "typing.Container", "typing.Sized", ): - # HEX: Synthesized base classes added by mypy don't exist at runtime, so skip them. + # HAX: Synthesized base classes added by mypy don't exist at runtime, so skip them. # This could break if they were added explicitly, though... continue # Add the current class to the base classes list of concrete subclasses @@ -529,7 +529,7 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value: base_ir.children.append(ir) if cls.fullname in MAGIC_TYPED_DICT_CLASSES: - # HEX: Mypy internally represents TypedDict classes differently from what + # HAX: Mypy internally represents TypedDict classes differently from what # should happen at runtime. Replace with something that works. module = "typing" if builder.options.capi_version < (3, 9): From 90e296fb5a89d495fba1827aef97b21e3121557e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clint=20Air=C3=A9?= <111376518+clintaire@users.noreply.github.com> Date: Mon, 16 Sep 2024 01:26:26 +0100 Subject: [PATCH 3/3] Update testtypes.py --- mypy/test/testtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/test/testtypes.py b/mypy/test/testtypes.py index 2ee2758cf67f..0218d33cc124 100644 --- a/mypy/test/testtypes.py +++ b/mypy/test/testtypes.py @@ -867,7 +867,7 @@ def test_generics_contravariant(self) -> None: def test_generics_with_multiple_args(self) -> None: self.assert_join(self.fx_co.hab, self.fx_co.hab, self.fx_co.hab) self.assert_join(self.fx_co.hab, self.fx_co.hbb, self.fx_co.hab) - self.assert_join(self.fx_co.had, self.fx_co.has, self.fx_co.hao) + self.assert_join(self.fx_co.had, self.fx_co.haa, self.fx_co.hao) def test_generics_with_inheritance(self) -> None: self.assert_join(self.fx_co.gsab, self.fx_co.gb, self.fx_co.gb)