Skip to content

Commit

Permalink
Edited files and fixed issues
Browse files Browse the repository at this point in the history
Staging unstaged changes before pull

Update testtypes.py
  • Loading branch information
clintaire committed Sep 16, 2024
1 parent 7a2ecf9 commit b2c35f9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions mypy/test/teststubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions mypy/test/testtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion mypy/test/typefixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions mypyc/ir/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypyc/irbuild/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion mypyc/irbuild/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
"""
Expand Down
8 changes: 4 additions & 4 deletions mypyc/test/test_namegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion mypyc/transform/refcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit b2c35f9

Please sign in to comment.