extension module work - #189
Merged
Merged
Conversation
Contributor
ecosystem checkLinter (stable)✅ ecosystem check detected no linter changes. Linter (preview)✅ ecosystem check detected no linter changes. Formatter (stable)✅ ecosystem check detected no format changes. Formatter (preview)✅ ecosystem check detected no format changes. |
Contributor
by ecosystem round-tripbase: regressions: 1, changed: 174, improvements: 0, error changes: 1 (across 25946 files in 148 projects) ❌ regressions (built on base, now fails)cryptography —ℹ️ changed round-trip outputalectryon — alectryon/lean3.py--- base/alectryon/lean3.py
+++ head/alectryon/lean3.py
@@ -217,6 +217,6 @@
def _parse_hyps(self, hyps):
for m in self.HYP_RE.finditer(hyps.strip()):
- names = m.group("names").split()
- typ = m.group("type").replace("\n ", "\n")
+ names = _soundness_check(m.group("names"), str).split()
+ typ = _soundness_check(m.group("type"), str).replace("\n ", "\n")
yield Hypothesis(names, None, typ)alectryon — alectryon/serapi.py--- base/alectryon/serapi.py
+++ head/alectryon/serapi.py
@@ -328,5 +328,5 @@
def _pprint_hyp(self, hyp, sid):
d = self.pp_args['pp_depth']
- name_w = _soundness_check(max(len(n) for n in _soundness_iter(hyp.names, str)), int)
+ name_w = _soundness_check(max(len(n) for n in hyp.names), int)
w = max(self.pp_args['pp_margin'] - name_w, SerAPI.MIN_PP_MARGIN)
body = self._pprint(hyp.body, sid, b'CoqExpr', d, w - 2).ppalectryon — etc/lint_changes.py--- base/etc/lint_changes.py
+++ head/etc/lint_changes.py
@@ -51,5 +51,5 @@
def subn(m):
- hashes = [sub1(h) for h in SINGLE_HASH.finditer(m.group())]
+ hashes = [_soundness_check(sub1(h), str) for h in SINGLE_HASH.finditer(m.group())]
return f"[{', '.join(sorted(hashes, key=commit_date))}]"attrs — tests/test_dunders.py--- base/tests/test_dunders.py
+++ head/tests/test_dunders.py
@@ -136,5 +136,5 @@
-InitC = _add_init(InitC, False)
+InitC = _soundness_check(_add_init(InitC, False), type)
@@ -846,5 +846,5 @@
]
- C = _add_init(C, False)
+ C = _soundness_check(_add_init(C, False), type)
i = C()
assert 2 == i.a
@@ -866,5 +866,5 @@
]
- C = _add_init(C, False)
+ C = _soundness_check(_add_init(C, False), type)
i = C()
@@ -961,5 +961,5 @@
__attrs_attrs__ = [simple_attr("_private")]
- C = _add_init(C, False)
+ C = _soundness_check(_add_init(C, False), type)
i = C(private=42)
assert 42 == i._privateattrs — tests/test_hooks.py--- base/tests/test_hooks.py
+++ head/tests/test_hooks.py
@@ -69,5 +69,5 @@
def hook(cls, attribs):
attr.resolve_types(cls, attribs=attribs)
- return [_soundness_check(a.evolve(converter=a.type), str) for a in attribs]
+ return [a.evolve(converter=a.type) for a in attribs]
@attr.s(auto_attribs=True, field_transformer=hook)beartype — beartype/typing/_typingpep544.py--- base/beartype/typing/_typingpep544.py
+++ head/beartype/typing/_typingpep544.py
@@ -423,5 +423,5 @@
# For the name of each attribute declared by this protocol class...
- for cls_attr_name in _soundness_iter(cls_attr_names, str):
+ for cls_attr_name in cls_attr_names:
# If...
if (cloud-init — cloudinit/cmd/clean.py--- base/cloudinit/cmd/clean.py
+++ head/cloudinit/cmd/clean.py
@@ -194,5 +194,5 @@
seed_path = os.path.join(init.paths.cloud_dir, "seed")
- for path in _soundness_iter(_soundness_check(glob.glob("%s/*" % init.paths.cloud_dir), list), str):
+ for path in _soundness_check(glob.glob("%s/*" % init.paths.cloud_dir), list):
if path == seed_path and not remove_seed:
continuecloud-init — cloudinit/cmd/status.py--- base/cloudinit/cmd/status.py
+++ head/cloudinit/cmd/status.py
@@ -451,5 +451,5 @@
errors = []
recoverable_errors = {}
- for _key, stage_info in sorted(status_v1.items()):
+ for _key, stage_info in _soundness_check(sorted(status_v1.items()), list):
if isinstance(stage_info, dict):
errors.extend(stage_info.get("errors", []))cloud-init — cloudinit/config/cc_apt_configure.py--- base/cloudinit/config/cc_apt_configure.py
+++ head/cloudinit/config/cc_apt_configure.py
@@ -379,8 +379,8 @@
if disabled_suite_names:
# Redact any matching Suites from line
- orig_suites = line.split()[1:]
+ orig_suites = _soundness_check(line.split()[1:], list)
new_suites = [
suite
- for suite in orig_suites
+ for suite in _soundness_iter(orig_suites, str)
if suite not in disabled_suite_names
]cloud-init — cloudinit/config/cc_ntp.py--- base/cloudinit/config/cc_ntp.py
+++ head/cloudinit/config/cc_ntp.py
@@ -504,5 +504,5 @@
" are required"
)
- for key, value in sorted(ntp_config.items()):
+ for key, value in _soundness_check(sorted(ntp_config.items()), list):
keypath = "ntp:config:" + key
if key == "confpath":cloud-init — cloudinit/handlers/jinja_template.py--- base/cloudinit/handlers/jinja_template.py
+++ head/cloudinit/handlers/jinja_template.py
@@ -109,5 +109,5 @@
Returns None on error.
"""
- if _soundness_check(_soundness_check(detect_template(payload), tuple)[0], str) != "jinja":
+ if _soundness_check(detect_template(payload)[0], str) != "jinja":
raise NotJinjaError("Payload is not a jinja template")
instance_data = {}
@@ -205,5 +205,5 @@
result = {}
decode_paths = [path.replace("-", "_") for path in decode_paths]
- for key, value in sorted(data.items()):
+ for key, value in _soundness_check(sorted(data.items()), list):
key_path = "{0}{1}{2}".format(prefix, sep, key) if prefix else key
if key_path in decode_paths:cloud-init — cloudinit/net/dhcp.py--- base/cloudinit/net/dhcp.py
+++ head/cloudinit/net/dhcp.py
@@ -666,5 +666,5 @@
latest_mtime = -1.0
- for fname in lease_files:
+ for fname in _soundness_iter(lease_files, str):
if not re.search(regex, fname):
continuecloud-init — cloudinit/net/sysconfig.py--- base/cloudinit/net/sysconfig.py
+++ head/cloudinit/net/sysconfig.py
@@ -127,5 +127,5 @@
if not isinstance(value, str):
value = str(value)
- buf.write("%s=%s\n" % (key, _soundness_check(_quote_value(value), str)))
+ buf.write("%s=%s\n" % (key, _quote_value(value)))
return buf.getvalue()
@@ -206,13 +206,13 @@
buf.write(
"%s=%s\n"
- % ("ADDRESS" + str(reindex), _soundness_check(_quote_value(address_value), str))
+ % ("ADDRESS" + str(reindex), _quote_value(address_value))
)
buf.write(
"%s=%s\n"
- % ("GATEWAY" + str(reindex), _soundness_check(_quote_value(gateway_value), str))
+ % ("GATEWAY" + str(reindex), _quote_value(gateway_value))
)
buf.write(
"%s=%s\n"
- % ("NETMASK" + str(reindex), _soundness_check(_quote_value(netmask_value), str))
... 198 characters elided ...
"%s=%s\n"
- % ("METRIC" + str(reindex), _soundness_check(_quote_value(metric_value), str))
+ % ("METRIC" + str(reindex), _quote_value(metric_value))
)
elif proto == "ipv6" and self.is_ipv6_route(address_value):cloud-init — cloudinit/sources/DataSourceNoCloud.py--- base/cloudinit/sources/DataSourceNoCloud.py
+++ head/cloudinit/sources/DataSourceNoCloud.py
@@ -115,5 +115,5 @@
}
- for path in _soundness_iter(self.seed_dirs, str):
+ for path in self.seed_dirs:
try:
seeded = util.pathprefix2dict(path, **pp2d_kwargs)cloud-init — cloudinit/sources/__init__.py--- base/cloudinit/sources/__init__.py
+++ head/cloudinit/sources/__init__.py
@@ -161,6 +161,6 @@
sens_keys.extend(return_val.pop("sensitive_keys"))
md_copy[key] = return_val
- md_copy["base64_encoded_keys"] = sorted(base64_encoded_keys)
- md_copy["sensitive_keys"] = sorted(sens_keys)
+ md_copy["base64_encoded_keys"] = _soundness_check(sorted(base64_encoded_keys), list)
+ md_copy["sensitive_keys"] = _soundness_check(sorted(sens_keys), list)
return md_copycloud-init — cloudinit/sources/helpers/digitalocean.py--- base/cloudinit/sources/helpers/digitalocean.py
+++ head/cloudinit/sources/helpers/digitalocean.py
@@ -191,5 +191,5 @@
continue
- sub_part = _get_subnet_part(raw_subnet)
+ sub_part = _soundness_check(_get_subnet_part(raw_subnet), dict)
if nic_type != "public" or "anchor" in netdef:
del sub_part["gateway"]cloud-init — cloudinit/templater.py--- base/cloudinit/templater.py
+++ head/cloudinit/templater.py
@@ -1,10 +1,2 @@
-def _soundness_check(_v, _t):
- if not isinstance(_v, _t):
- raise TypeError(
- f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
- f"got {type(_v).__name__}"
- )
- return _v
-
# Copyright (C) 2012 Canonical Ltd.
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
@@ -182,5 +174,5 @@
if not params:
params = {}
- template_type, renderer, content = _soundness_check(detect_template(util.load_text_file(fn)), tuple)
+ template_type, renderer, content = detect_template(util.load_text_file(fn))
LOG.debug("Rendering content of '%s' using renderer %s", fn, template_type)
return renderer(content, params)
@@ -196,5 +188,5 @@
if not params:
params = {}
- _template_type, renderer, content = _soundness_check(detect_template(content), tuple)
+ _template_type, renderer, content = detect_template(content)
return renderer(content, params)cloud-init — tests/integration_tests/conftest.py--- base/tests/integration_tests/conftest.py
+++ head/tests/integration_tests/conftest.py
@@ -395,7 +395,7 @@
userdata, yield to the test, then cleanup
"""
- user_data, launch_kwargs, lxd_setup, lxd_use_exec = get_session_args(
+ user_data, launch_kwargs, lxd_setup, lxd_use_exec = _soundness_check(get_session_args(
request, fixture_utils, session_cloud
- )
+ ), tuple)
with session_cloud.launch(cloud-init — tests/integration_tests/datasources/test_ec2_ipv6.py--- base/tests/integration_tests/datasources/test_ec2_ipv6.py
+++ head/tests/integration_tests/datasources/test_ec2_ipv6.py
@@ -29,5 +29,5 @@
# 20 would still be a crazy long time for metadata service to crawl,
# but it's short enough to know we're not waiting for a response
- assert float(result[0]) < 20
+ assert float(_soundness_check(result[0], str)) < 20cloud-init — tests/unittests/config/test_cc_ntp.py--- base/tests/unittests/config/test_cc_ntp.py
+++ head/tests/unittests/config/test_cc_ntp.py
@@ -301,5 +301,5 @@
continue
# Create a copy in our tmp_dir
- _soundness_check(shutil.copy(source_fn, template_fn), str)
+ shutil.copy(source_fn, template_fn)
cc_ntp.write_ntp_config_template(
distro,cloud-init — tests/unittests/config/test_cc_rsyslog.py--- base/tests/unittests/config/test_cc_rsyslog.py
+++ head/tests/unittests/config/test_cc_rsyslog.py
@@ -359,5 +359,5 @@
) as m_install:
handle("rsyslog", {"rsyslog": config}, cloud, [])
- m_which.assert_called_with(config["check_exe"])
+ m_which.assert_called_with(_soundness_check(config["check_exe"], str))
m_install.assert_called_with(_soundness_check(config["packages"], list))
@@ -375,4 +375,4 @@
with mock.patch.object(cloud.distro, "install_packages") as m_install:
handle("rsyslog", {"rsyslog": config}, cloud, [])
- m_which.assert_called_with(config["check_exe"])
+ m_which.assert_called_with(_soundness_check(config["check_exe"], str))
m_install.assert_not_called()cloud-init — tests/unittests/net/test_netplan.py--- base/tests/unittests/net/test_netplan.py
+++ head/tests/unittests/net/test_netplan.py
@@ -1,2 +1,10 @@
+def _soundness_check(_v, _t):
+ if not isinstance(_v, _t):
+ raise TypeError(
+ f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
+ f"got {type(_v).__name__}"
+ )
+ return _v
+
lazy import os
lazy from unittest import mock
@@ -34,6 +42,6 @@
util.ensure_dir(os.path.dirname(renderer.netplan_path))
with open(renderer.netplan_path, "w") as f:
- f.write(header)
- f.write(orig_config)
+ _soundness_check(f.write(header), int)
+ _soundness_check(f.write(orig_config), int)
renderer.render_network_state(mocker.Mock())
config_changed = bool(orig_config != new_config)cloud-init — tests/unittests/sources/test_gce.py--- base/tests/unittests/sources/test_gce.py
+++ head/tests/unittests/sources/test_gce.py
@@ -109,5 +109,5 @@
url_path = urlparse(request.url).path
if url_path.startswith("/computeMetadata/v1/"):
- path = url_path.split("/computeMetadata/v1/")[1:][0]
+ path = _soundness_check(_soundness_check(url_path.split("/computeMetadata/v1/")[1:], list)[0], str)
recursive = path.endswith("/")
path = path.rstrip("/")cloud-init — tests/unittests/sources/test_openstack.py--- base/tests/unittests/sources/test_openstack.py
+++ head/tests/unittests/sources/test_openstack.py
@@ -142,5 +142,5 @@
uri = urlparse(request.url)
path = uri.path.lstrip("/").split("/")
- if path[0] == "openstack":
+ if _soundness_check(path[0], str) == "openstack":
return _soundness_check(match_os_uri(uri, request.headers), tuple)
return _soundness_check(match_ec2_url(uri, request.headers), tuple)
@@ -512,5 +512,5 @@
"vendordata2",
"version",
- ] == sorted(crawled_data.keys())
+ ] == _soundness_check(sorted(crawled_data.keys()), list)
assert "local" == crawled_data["dsmode"]
assert EC2_META == crawled_data["ec2-metadata"]
@@ -786,5 +786,5 @@
def register_version(self, version, data):
- content = "\n".join(sorted(data.keys()))
+ content = "\n".join(_soundness_check(sorted(data.keys()), list))
self.register(version, content)
self.register(version + "/", content)cloud-init — tests/unittests/test_merging.py--- base/tests/unittests/test_merging.py
+++ head/tests/unittests/test_merging.py
@@ -110,5 +110,5 @@
max_depth = max(1, max_depth)
rand = random.Random(seed)
- return _soundness_check(_make_dict(0, max_depth, rand), (type(None), dict, list, int, str, tuple))
+ return _make_dict(0, max_depth, rand)cloud-init — tests/unittests/test_render_template.py--- base/tests/unittests/test_render_template.py
+++ head/tests/unittests/test_render_template.py
@@ -51,5 +51,5 @@
subp.subp(self.cmd + ["--variant", "ubuntu", self.tmpl_path, outfile])
with open(outfile) as stream:
- system_cfg = util.load_yaml(stream.read())
+ system_cfg = util.load_yaml(_soundness_check(stream.read(), str))
assert system_cfg["system_info"]["distro"] == "ubuntu"
@@ -69,5 +69,5 @@
)
with open(outfile) as stream:
- init_cfg = stream.readlines()
+ init_cfg = _soundness_check(stream.readlines(), list)
assert 'command="/usr/local/lib/cloud-init/ds-identify"\n' in init_cfg
@@ -83,5 +83,5 @@
)
with open(outfile) as stream:
- system_cfg = util.load_yaml(stream.read())
+ system_cfg = util.load_yaml(_soundness_check(stream.read(), str))
if variant == "unknown":
variant = "ubuntu" # Unknown is defaulted to ubuntu
@@ -98,5 +98,5 @@
)
with open(outfile) as stream:
- system_cfg = util.load_yaml(stream.read())
... 80 characters elided ...
default_user_exceptions = {
@@ -132,5 +132,5 @@
)
with open(outfile) as stream:
- system_cfg = util.load_yaml(stream.read())
+ system_cfg = util.load_yaml(_soundness_check(stream.read(), str))
assert renderers == system_cfg["system_info"]["network"]["renderers"]dulwich — tests/test_sparse_patterns.py--- base/tests/test_sparse_patterns.py
+++ head/tests/test_sparse_patterns.py
@@ -397,5 +397,5 @@
content = b"hello"
full = os.path.join(self.temp_dir, relpath)
- os.makedirs(os.path.dirname(full), exist_ok=True)
+ os.makedirs(_soundness_check(os.path.dirname(full), str), exist_ok=True)
with open(full, "wb") as f:
_soundness_check(f.write(content), int)dulwich — tests/test_web.py--- base/tests/test_web.py
+++ head/tests/test_web.py
@@ -796,5 +796,5 @@
self._environ["wsgi.input"] = zstream
self._app(self._environ, None)
- buf = _soundness_check(self._environ["wsgi.input"], str)
+ buf = self._environ["wsgi.input"]
self.assertIsNot(buf, zstream)
buf.seek(0)graphql-core — tests/language/test_visitor.py--- base/tests/language/test_visitor.py
+++ head/tests/language/test_visitor.py
@@ -73,5 +73,5 @@
current_node = ast
- for i, ancestor in enumerate(ancestors):
+ for i, ancestor in enumerate[object](ancestors):
assert ancestor is current_node
k = path[i]hydra-zen — tests/test_launch/test_logging.py--- base/tests/test_launch/test_logging.py
+++ head/tests/test_launch/test_logging.py
@@ -23,5 +23,5 @@
def task(cfg):
- instantiate(cfg)
+ _soundness_check(instantiate(cfg), Path)
log.info(f"message: {cfg['message']}")hydra-zen — tests/test_signature_parsing.py--- base/tests/test_signature_parsing.py
+++ head/tests/test_signature_parsing.py
@@ -588,5 +588,5 @@
# Ensure that `builds` inspects __new__ for signature and annotations
# with same priority as `inspect.signature` in Python >= 3.9.1
- Conf = builds(Obj, populate_full_signature=True)
+ Conf = _soundness_check(builds(Obj, populate_full_signature=True), type)
sig_via_builds = tuple(ibis — ibis/backends/bigquery/tests/system/test_client.py--- base/ibis/backends/bigquery/tests/system/test_client.py
+++ head/ibis/backends/bigquery/tests/system/test_client.py
@@ -522,5 +522,5 @@
query_parameters = {cutoff: value}
result = con.raw_sql(f"SELECT @{name} AS {name}", params=query_parameters)
- assert list[dict[str, str] | dict[bytes, bytes]](map[dict[str, str] | dict[bytes, bytes]](dict, result)) == [{name: value}]
+ assert list(map(dict, result)) == [{name: value}]ibis — ibis/backends/bigquery/tests/unit/udf/test_find.py--- base/ibis/backends/bigquery/tests/unit/udf/test_find.py
+++ head/ibis/backends/bigquery/tests/unit/udf/test_find.py
@@ -21,5 +21,5 @@
if is_iterable(left) and is_iterable(right):
- return all(map[bool](eq, left, right))
+ return all(map(eq, left, right))
if not isinstance(left, ast.AST) and not isinstance(right, ast.AST):ibis — ibis/backends/datafusion/tests/test_connect.py--- base/ibis/backends/datafusion/tests/test_connect.py
+++ head/ibis/backends/datafusion/tests/test_connect.py
@@ -39,5 +39,5 @@
with pytest.warns(FutureWarning):
conn = ibis.datafusion.connect(config)
- assert _soundness_check(sorted(conn.list_tables()), list) == sorted(name_to_path)
+ assert _soundness_check(sorted(conn.list_tables()), list) == _soundness_check(sorted(name_to_path), list)
@@ -54,3 +54,3 @@
ctx.register_parquet(name, str(path))
conn = ibis.datafusion.connect(ctx)
- assert _soundness_check(sorted(conn.list_tables()), list) == sorted(name_to_path)
+ assert _soundness_check(sorted(conn.list_tables()), list) == _soundness_check(sorted(name_to_path), list)ibis — ibis/backends/flink/ddl.py--- base/ibis/backends/flink/ddl.py
+++ head/ibis/backends/flink/ddl.py
@@ -38,5 +38,5 @@
def format_properties(self, props):
tokens = []
- for k, v in sorted(props.items()):
+ for k, v in _soundness_check(sorted(props.items()), list):
tokens.append(f" '{k}'='{v}'")
return "(\n{}\n)".format(",\n".join(tokens))ibis — ibis/backends/flink/tests/test_ddl.py--- base/ibis/backends/flink/tests/test_ddl.py
+++ head/ibis/backends/flink/tests/test_ddl.py
@@ -368,5 +368,5 @@
overwrite=False,
)
- view_list = sorted(con.list_tables())
+ view_list = _soundness_check(sorted(con.list_tables()), list)
assert temp_view in view_list
@@ -380,5 +380,5 @@
overwrite=False,
)
- assert view_list == sorted(con.list_tables())
+ assert view_list == _soundness_check(sorted(con.list_tables()), list)
# Try to re-create the same view with `force=True`
@@ -390,5 +390,5 @@
overwrite=False,
)
- assert view_list == sorted(con.list_tables())
+ assert view_list == _soundness_check(sorted(con.list_tables()), list)
# Overwrite the view
@@ -400,5 +400,5 @@
overwrite=True,
)
- assert view_list == sorted(con.list_tables())
+ assert view_list == _soundness_check(sorted(con.list_tables()), list)
con.drop_view(temp_view, temp=temp, force=True)ibis — ibis/backends/impala/ddl.py--- base/ibis/backends/impala/ddl.py
+++ head/ibis/backends/impala/ddl.py
@@ -45,5 +45,5 @@
def format_properties(self, props):
tokens = []
- for k, v in sorted(props.items()):
+ for k, v in _soundness_check(sorted(props.items()), list):
tokens.append(f" '{k}'='{v}'")
return "(\n{}\n)".format(",\n".join(tokens))ibis — ibis/backends/sql/compilers/base.py--- base/ibis/backends/sql/compilers/base.py
+++ head/ibis/backends/sql/compilers/base.py
@@ -824,5 +824,5 @@
return sge.convert(str(value))
elif dtype.is_timestamp() or dtype.is_time():
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
elif dtype.is_date():
return self.f.datefromparts(value.year, value.month, value.day)ibis — ibis/backends/sql/compilers/exasol.py--- base/ibis/backends/sql/compilers/exasol.py
+++ head/ibis/backends/sql/compilers/exasol.py
@@ -114,5 +114,5 @@
def visit_NonNullLiteral(self, op, *, value, dtype):
if dtype.is_date():
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
elif dtype.is_timestamp():
val = value.replace(tzinfo=None).isoformat(sep=" ", timespec="milliseconds")ibis — ibis/backends/sql/compilers/flink.py--- base/ibis/backends/sql/compilers/flink.py
+++ head/ibis/backends/sql/compilers/flink.py
@@ -239,5 +239,5 @@
if dtype.is_binary():
# TODO: is this decode safe?
- return self.cast(object, dtype)
+ return self.cast(value.decode(), dtype)
elif dtype.is_uuid():
return sge.convert(str(value))
@@ -281,5 +281,5 @@
)
elif dtype.is_date():
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
elif dtype.is_time():
return self.cast(value.isoformat(timespec="microseconds"), dtype)ibis — ibis/backends/sql/compilers/materialize.py--- base/ibis/backends/sql/compilers/materialize.py
+++ head/ibis/backends/sql/compilers/materialize.py
@@ -306,5 +306,5 @@
if dtype.is_date():
# Use ISO format string and cast to date
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
# Delegate to parent for other typesibis — ibis/backends/sql/compilers/risingwave.py--- base/ibis/backends/sql/compilers/risingwave.py
+++ head/ibis/backends/sql/compilers/risingwave.py
@@ -173,5 +173,5 @@
return self.cast("".join(map[object](r"\x{:0>2x}".format, value)), dt.binary)
elif dtype.is_date():
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
elif dtype.is_json():
return sge.convert(str(value))
@@ -249,5 +249,5 @@
)
.from_(
- window_func(*filter[object](None, args)).as_(parent.alias_or_name, quoted=True)
+ window_func(*filter(None, args)).as_(parent.alias_or_name, quoted=True)
)
.group_by(ibis — ibis/backends/sql/compilers/trino.py--- base/ibis/backends/sql/compilers/trino.py
+++ head/ibis/backends/sql/compilers/trino.py
@@ -419,5 +419,5 @@
return self.f.from_iso8601_date(value.isoformat())
elif dtype.is_time():
- return self.cast(object, dtype)
+ return self.cast(value.isoformat(), dtype)
elif dtype.is_interval():
return self._make_interval(sge.convert(str(value)), dtype.unit)ibis — ibis/backends/tests/test_aggregation.py--- base/ibis/backends/tests/test_aggregation.py
+++ head/ibis/backends/tests/test_aggregation.py
@@ -1516,5 +1516,5 @@
if not ordered:
# If unordered, order afterwards so we can compare
- res = sorted(res, key=lambda x: (x is not None, x), reverse=True)
+ res = _soundness_check(sorted(res, key=lambda x: (x is not None, x), reverse=True), list)
assert res == solibis — ibis/backends/tests/test_array.py--- base/ibis/backends/tests/test_array.py
+++ head/ibis/backends/tests/test_array.py
@@ -120,5 +120,5 @@
expr = left + right
result = con.execute(expr.name("tmp"))
- assert sorted(result) == _soundness_check(sorted([1, 2, 3, 2, 1]), list)
+ assert _soundness_check(sorted(result), list) == _soundness_check(sorted([1, 2, 3, 2, 1]), list)ibis — ibis/backends/tests/test_generic.py--- base/ibis/backends/tests/test_generic.py
+++ head/ibis/backends/tests/test_generic.py
@@ -959,7 +959,7 @@
expr = sometypes.describe()
df = expr.execute()
- assert sorted(sometypes.columns) == sorted(df.name)
- assert sorted(expr.columns) == _soundness_check(sorted(expected_columns), list)
- assert sorted(expr.columns) == sorted(df.columns)
+ assert _soundness_check(sorted(sometypes.columns), list) == _soundness_check(sorted(df.name), list)
+ assert _soundness_check(sorted(expr.columns), list) == _soundness_check(sorted(expected_columns), list)
+ assert _soundness_check(sorted(expr.columns), list) == _soundness_check(sorted(df.columns), list)
@@ -2517,5 +2517,5 @@
expr = t.a
expected = [1.0, 2.0]
- assert sorted(con.to_pandas(expr).tolist()) == expected
+ assert _soundness_check(sorted(con.to_pandas(expr).tolist()), list) == expectedibis — ibis/backends/tests/test_numeric.py--- base/ibis/backends/tests/test_numeric.py
+++ head/ibis/backends/tests/test_numeric.py
@@ -1,2 +1,10 @@
+def _soundness_check(_v, _t):
+ if not isinstance(_v, _t):
+ raise TypeError(
+ f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
+ f"got {type(_v).__name__}"
+ )
+ return _v
+
lazy import contextlib
@@ -1696,5 +1704,5 @@
result = con.execute(expr)
- one, three = sorted(result.tolist())
+ one, three = _soundness_check(sorted(result.tolist()), list)
assert one == 1ibis — ibis/backends/tests/test_struct.py--- base/ibis/backends/tests/test_struct.py
+++ head/ibis/backends/tests/test_struct.py
@@ -95,5 +95,5 @@
def test_struct_column(alltypes, df):
t = alltypes
- expr = t.select(s=ibis.struct(dict[str, object](a=t.string_col, b=1, c=t.bigint_col)))
+ expr = t.select(s=ibis.struct(dict(a=t.string_col, b=1, c=t.bigint_col)))
assert expr.s.type() == dt.Struct(dict(a=dt.string, b=dt.int8, c=dt.int64))
result = expr.execute()ibis — ibis/common/dispatch.py--- base/ibis/common/dispatch.py
+++ head/ibis/common/dispatch.py
@@ -1,14 +1,2 @@
-def _soundness_check(_v, _t):
- if not isinstance(_v, _t):
- raise TypeError(
- f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
- f"got {type(_v).__name__}"
- )
- return _v
-
-def _soundness_iter(_it, _t):
- for _x in _it:
- yield _soundness_check(_x, _t)
-
lazy import abc
@@ -73,5 +61,5 @@
def dispatch(self, typ):
"""Return the implementation for the given `cls`."""
- for klass in _soundness_iter(typ.__mro__, type):
+ for klass in typ.__mro__:
# 1. Check for a concrete implementation
try:
@@ -85,5 +73,5 @@
return impl
# 2. Check lazy implementations
- package = _soundness_check(klass.__module__.split(".", 1)[0], str)
+ package = klass.__module__.split(".", 1)[0]
if lazy := self.lazy_lookup.get(package):
# Import all lazy implementations first before registeringibis — ibis/tests/expr/test_table.py--- base/ibis/tests/expr/test_table.py
+++ head/ibis/tests/expr/test_table.py
@@ -2110,5 +2110,5 @@
assert isinstance(left, tuple)
assert isinstance(right, tuple)
- return all(a.equals(b) for a, b in zip(left, right))
+ return all(a.equals(b) for a, b in zip[tuple[object, object]](left, right))
t = ibis.table({"a": "int", "b": "string"}, name="t")ibis — ibis/tests/expr/test_window_functions.py--- base/ibis/tests/expr/test_window_functions.py
+++ head/ibis/tests/expr/test_window_functions.py
@@ -38,5 +38,5 @@
]
- exprs = [expr.name(f"e{i:d}") for i, expr in enumerate[object](exprs)]
+ exprs = [expr.name(f"e{i:d}") for i, expr in enumerate(exprs)]
proj = g.mutate(exprs)ignite — examples/mnist/mnist_save_resume_engine.py--- base/examples/mnist/mnist_save_resume_engine.py
+++ head/examples/mnist/mnist_save_resume_engine.py
@@ -1,2 +1,10 @@
+def _soundness_check(_v, _t):
+ if not isinstance(_v, _t):
+ raise TypeError(
+ f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
+ f"got {type(_v).__name__}"
+ )
+ return _v
+
lazy from argparse import ArgumentParser
lazy from pathlib import Path
@@ -86,6 +94,6 @@
with open(fp, "a") as h:
- h.write(msg)
- h.write("\n")
+ _soundness_check(h.write(msg), int)
+ _soundness_check(h.write("\n"), int)
@@ -109,6 +117,6 @@
with open(fp, "a") as h:
- h.write(msg)
- h.write("\n")
+ _soundness_check(h.write(msg), int)
+ _soundness_check(h.write("\n"), int)imagehash — _by_sourcemap.py--- base/_by_sourcemap.py
+++ head/_by_sourcemap.py
@@ -30,5 +30,5 @@
"/tmp/tmp3hiszbj2/imagehash/out/examples/crop_resistant_segmentation.py": {"by": "sha256:bf0c6b637402262025e159628a2520dd4bb9b303fe67db861d8873b4de304eba", "py": "sha256:d0dc047efac6c74973cfe17bbe2037d34298dd000c5318a953774d5bde0b62b8"},
"/tmp/tmp3hiszbj2/imagehash/out/examples/hashimages.py": {"by": "sha256:8df7d061dc69ffa3e04cd2cf31ad97954d1e8d1c70bf2ccf3c961e1b755b22e0", "py": "sha256:96e79145b5e27f0699b59b710e064057a17aeec526b19f35c83738009daf25a1"},
- "/tmp/tmp3hiszbj2/imagehash/out/find_similar_images.py": {"by": "sha256:1046b30b719d32fd1f76aecf3d7fd27f7f8cd38341026378bc1ba495e8f0f7ad", "py": "sha256:39f9df6b5c0decc6f68bd5158778bf61e618e8f1e9bd5402a4ba813e40ca6728"},
+ "/tmp/tmp3hiszbj2/imagehash/out/find_similar_images.py": {"by": "sha256:1046b30b719d32fd1f76aecf3d7fd27f7f8cd38341026378bc1ba495e8f0f7ad", "py": "sha256:b51aadbdd34b445879c68841ee2bf2bcbba31f3c3375b61db6e7624d319eae2f"},
"/tmp/tmp3hiszbj2/imagehash/out/imagehash/__init__.py": {"by": "sha256:27b9543c1db1a6948e26f378c7e359db11861caf5538a9e7f235f3b3954c7270", "py": "sha256:e1cd8b53bf116085e0684e1ccd1cd9f1c45be70ae6d8b94b83de35c604a6be70"},
"/tmp/tmp3hiszbj2/imagehash/out/setup.py": {"by": "sha256:63dfa723ad59079bed46e09ee332c3dd2b760bd7b375d6615dba1f6c32cab87f", "py": "sha256:c0f35ede766250e25ccc410d324c4a451e9252c55af77fff739d4e02c61e4c94"},imagehash — find_similar_images.py--- base/find_similar_images.py
+++ head/find_similar_images.py
@@ -30,5 +30,5 @@
image_filenames = []
for userpath in userpaths:
- image_filenames += [os.path.join(userpath, path) for path in os.listdir(userpath) if _soundness_check(is_image(path), bool)]
+ image_filenames += [os.path.join(userpath, path) for path in os.listdir(userpath) if is_image(path)]
images = {}
for img in _soundness_check(sorted(image_filenames), list):isort — tests/unit/test_isort.py--- base/tests/unit/test_isort.py
+++ head/tests/unit/test_isort.py
@@ -78,5 +78,5 @@
with open(config_file, "w") as editorconfig:
- editorconfig.write(TEST_DEFAULT_CONFIG)
+ _soundness_check(editorconfig.write(TEST_DEFAULT_CONFIG), int)
assert Config(config_file).known_otherjinja — tests/test_compile.py--- base/tests/test_compile.py
+++ head/tests/test_compile.py
@@ -22,5 +22,5 @@
env.filters.update(_soundness_check(dict.fromkeys((f"filter{i}" for i in range(10)), lambda: None), dict))
env.compile_templates(tmp_path, zip=None)
- name = _soundness_check(os.listdir(tmp_path)[0], str)
+ name = os.listdir(tmp_path)[0]
content = (tmp_path / name).read_text("utf8")
expect = [f"filters['filter{i}']" for i in range(10)]
@@ -33,5 +33,5 @@
env = Environment(loader=DictLoader({"foo": src}))
env.compile_templates(tmp_path, zip=None)
- name = _soundness_check(os.listdir(tmp_path)[0], str)
+ name = os.listdir(tmp_path)[0]
content = (tmp_path / name).read_text("utf8")
expect = [f"'bar{i}': " for i in range(10)]
@@ -44,5 +44,5 @@
env = Environment(loader=DictLoader({"foo": src}))
env.compile_templates(tmp_path, zip=None)
- name = _soundness_check(os.listdir(tmp_path)[0], str)
+ name = os.listdir(tmp_path)[0]
content = (tmp_path / name).read_text("utf8")
expect = [
@@ -70,5 +70,5 @@
env = Environment(loader=DictLoader({"foo": src}))
... 194 characters elided ...
expect = [
@@ -88,5 +88,5 @@
env = Environment(loader=DictLoader({"foo": src}))
env.compile_templates(tmp_path, zip=None)
- name = _soundness_check(os.listdir(tmp_path)[0], str)
+ name = os.listdir(tmp_path)[0]
content = (tmp_path / name).read_text("utf8")
expect = [mitmproxy — examples/contrib/link_expander.py--- base/examples/contrib/link_expander.py
+++ head/examples/contrib/link_expander.py
@@ -34,6 +34,6 @@
map_dict = {}
for match_num, match in enumerate(rel_matches):
- (delimiter, rel_link) = match.group("delimiter", "link")
- abs_link = urljoin(pageUrl, rel_link)
+ (delimiter, rel_link) = _soundness_check(match.group("delimiter", "link"), tuple)
+ abs_link = _soundness_check(urljoin(pageUrl, rel_link), str)
map_dict["{0}{1}{0}".format(delimiter, rel_link)] = "{0}{1}{0}".format(
delimiter, abs_linkmitmproxy — examples/contrib/search.py--- base/examples/contrib/search.py
+++ head/examples/contrib/search.py
@@ -83,14 +83,14 @@
def flow_results(self, _flow):
results = dict()
- results.update({"flow_comment": self.exp.findall(_flow.comment)})
+ results.update({"flow_comment": _soundness_check(self.exp.findall(_flow.comment), list)})
if _flow.request is not None:
- results.update({"request_path": self.exp.findall(_flow.request.path)})
+ results.update({"request_path": _soundness_check(self.exp.findall(_flow.request.path), list)})
results.update({"request_headers": self.header_results(_flow.request)})
if _flow.request.text:
- results.update({"request_body": self.exp.findall(_flow.request.text)})
+ results.update({"request_body": _soundness_check(self.exp.findall(_flow.request.text), list)})
if _flow.response is not None:
results.update({"response_headers": self.header_results(_flow.response)})
if _flow.response.text:
- results.update({"response_body": self.exp.findall(_flow.response.text)})
+ results.update({"response_body": _soundness_check(self.exp.findall(_flow.response.text), list)})
return resultsmitmproxy — examples/contrib/webscanner_helper/test_urldict.py--- base/examples/contrib/webscanner_helper/test_urldict.py
+++ head/examples/contrib/webscanner_helper/test_urldict.py
@@ -34,5 +34,5 @@
tmpfile = tmpdir.join("tmpfile")
with open(tmpfile, "w") as tfile:
- tfile.write(input_file_content_error)
+ _soundness_check(tfile.write(input_file_content_error), int)
with open(tmpfile) as tfile:
try:
@@ -46,5 +46,5 @@
tmpfile = tmpdir.join("tmpfile")
with open(tmpfile, "w") as tfile:
- tfile.write(input_file_content)
+ _soundness_check(tfile.write(input_file_content), int)
with open(tmpfile) as tfile:
urldict = _soundness_check(URLDict.load(tfile), URLDict)
@@ -76,5 +76,5 @@
tmpfile = tmpdir.join("tmpfile")
with open(tmpfile, "w") as tfile:
- tfile.write(input_file_content)
+ _soundness_check(tfile.write(input_file_content), int)
with open(tmpfile) as tfile:
urldict = _soundness_check(URLDict.load(tfile), URLDict)
@@ -87,5 +87,5 @@
outfile = tmpdir.join("outfile")
with open(tmpfile, "w") as tfile:
- tfile.write(input_file_content)
+ _soundness_check(tfile.write(input_file_content), int)
with open(tmpfile) as tfile:
urldict = _soundness_check(URLDict.load(tfile), URLDict)mitmproxy — examples/contrib/webscanner_helper/test_urlindex.py--- base/examples/contrib/webscanner_helper/test_urlindex.py
+++ head/examples/contrib/webscanner_helper/test_urlindex.py
@@ -57,7 +57,7 @@
tmpfile = tmpdir.join("tmpfile")
with open(tmpfile, "w") as tfile:
- tfile.write(
+ _soundness_check(tfile.write(
'{"http://example.com:80": {"/": {"GET": [301]}}, "http://www.example.com:80": {"/": {"GET": [302]}}}'
- )
+ ), int)
writer = JSONUrlIndexWriter(filename=tmpfile)
writer.load()
@@ -70,5 +70,5 @@
tmpfile = tmpdir.join("tmpfile")
with open(tmpfile, "w") as tfile:
- tfile.write("{}")
+ _soundness_check(tfile.write("{}"), int)
writer = JSONUrlIndexWriter(filename=tmpfile)
writer.load()mitmproxy — mitmproxy/addons/view.py--- base/mitmproxy/addons/view.py
+++ head/mitmproxy/addons/view.py
@@ -727,5 +727,5 @@
self.flow = self.view[0]
elif self.flow not in self.view:
- self.flow = self.view[self._nearest(self.flow, self.view)]
+ self.flow = self.view[_soundness_check(self._nearest(self.flow, self.view), int)]
def _sig_view_add(self, flow):mitmproxy — mitmproxy/optmanager.py--- base/mitmproxy/optmanager.py
+++ head/mitmproxy/optmanager.py
@@ -494,5 +494,5 @@
# Sort data
s = ruamel.yaml.comments.CommentedMap()
- for k in sorted(opts.keys()):
+ for k in _soundness_check(sorted(opts.keys()), list):
o = opts._options[k]
s[k] = o.default
@@ -519,5 +519,5 @@
if keys is None:
keys = opts.keys()
- for k in sorted(keys):
+ for k in _soundness_iter(_soundness_check(sorted(keys), list), str):
o = opts._options[k]
t = typecheck.typespec_to_str(o.typespec)mitmproxy — mitmproxy/tools/console/options.py--- base/mitmproxy/tools/console/options.py
+++ head/mitmproxy/tools/console/options.py
@@ -100,5 +100,5 @@
self.focusobj = None
- self.opts = sorted(master.options.keys())
+ self.opts = _soundness_check(sorted(master.options.keys()), list)
self.maxlen = _soundness_check(max(len(i) for i in self.opts), int)
self.editing = Falsemitmproxy — test/mitmproxy/addons/test_command_history.py--- base/test/mitmproxy/addons/test_command_history.py
+++ head/test/mitmproxy/addons/test_command_history.py
@@ -24,5 +24,5 @@
commands = ["cmd1", "cmd2", "cmd3"]
with open(history_file, "w") as f:
- f.write("\n".join(commands))
+ _soundness_check(f.write("\n".join(commands)), int)
ch = command_history.CommandHistory()
@@ -35,5 +35,5 @@
with open(history_file) as f:
- assert f.read() == "cmd3\ncmd4\n"
+ assert _soundness_check(f.read(), str) == "cmd3\ncmd4\n"
async def test_done_writing_failed(self, caplog):mitmproxy — test/mitmproxy/addons/test_cut.py--- base/test/mitmproxy/addons/test_cut.py
+++ head/test/mitmproxy/addons/test_cut.py
@@ -61,5 +61,5 @@
with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
c1 = certs.Cert.from_pem(d)
tf.server_conn.certificate_list = [c1]mitmproxy — test/mitmproxy/addons/test_tlsconfig.py--- base/test/mitmproxy/addons/test_tlsconfig.py
+++ head/test/mitmproxy/addons/test_tlsconfig.py
@@ -194,5 +194,5 @@
"rb",
) as f:
- ctx.server.certificate_list = [certs.Cert.from_pem(f.read())]
+ ctx.server.certificate_list = [certs.Cert.from_pem(_soundness_check(f.read(), bytes))]
entry = ta.get_cert(ctx)
assert entry.cert.cn == "example.mitmproxy.org"
@@ -552,5 +552,5 @@
ctx = _ctx(tctx.options)
with open(tdata.path(cert), "rb") as f:
- ctx.server.certificate_list = [certs.Cert.from_pem(f.read())]
+ ctx.server.certificate_list = [certs.Cert.from_pem(_soundness_check(f.read(), bytes))]
crt = ta.get_cert(ctx)mitmproxy — test/mitmproxy/contentviews/_view_image/test_image_parser.py--- base/test/mitmproxy/contentviews/_view_image/test_image_parser.py
+++ head/test/mitmproxy/contentviews/_view_image/test_image_parser.py
@@ -1,2 +1,10 @@
+def _soundness_check(_v, _t):
+ if not isinstance(_v, _t):
+ raise TypeError(
+ f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
+ f"got {type(_v).__name__}"
+ )
+ return _v
+
lazy import pytest
@@ -85,5 +93,5 @@
def test_parse_png(filename, metadata, tdata):
with open(tdata.path(filename), "rb") as f:
- assert metadata == image_parser.parse_png(f.read())
+ assert metadata == image_parser.parse_png(_soundness_check(f.read(), bytes))
@@ -118,5 +126,5 @@
def test_parse_gif(filename, metadata, tdata):
with open(tdata.path(filename), "rb") as f:
- assert metadata == image_parser.parse_gif(f.read())
+ assert metadata == image_parser.parse_gif(_soundness_check(f.read(), bytes))
@@ -187,5 +195,5 @@
def test_parse_jpeg(filename, metadata, tdata):
with open(tdata.path(filename), "rb") as f:
- assert metadata == image_parser.parse_jpeg(f.read())
+ assert metadata == image_parser.parse_jpeg(_soundness_check(f.read(), bytes))
@@ -220,4 +228,4 @@
def test_ico(filename, metadata, tdata):
with open(tdata.path(filename), "rb") as f:
- assert metadata == image_parser.parse_ico(f.read())
+ assert metadata == image_parser.parse_ico(_soundness_check(f.read(), bytes))
# fmt: onmitmproxy — test/mitmproxy/contentviews/_view_image/test_view.py--- base/test/mitmproxy/contentviews/_view_image/test_view.py
+++ head/test/mitmproxy/contentviews/_view_image/test_view.py
@@ -23,5 +23,5 @@
], str):
with open(tdata.path(img), "rb") as f:
- desc = image.prettify(f.read(), Metadata())
+ desc = image.prettify(_soundness_check(f.read(), bytes), Metadata())
assert img.split(".")[-1].upper() in descmitmproxy — test/mitmproxy/contentviews/test__view_css.py--- base/test/mitmproxy/contentviews/test__view_css.py
+++ head/test/mitmproxy/contentviews/test__view_css.py
@@ -31,5 +31,5 @@
path = tdata.path("mitmproxy/contentviews/test_css_data/" + filename)
with open(path, "rb") as f:
- input = f.read()
+ input = _soundness_check(f.read(), bytes)
with open("-formatted.".join(path.rsplit(".", 1))) as f:
expected = _soundness_check(f.read(), str)mitmproxy — test/mitmproxy/contentviews/test__view_javascript.py--- base/test/mitmproxy/contentviews/test__view_javascript.py
+++ head/test/mitmproxy/contentviews/test__view_javascript.py
@@ -32,5 +32,5 @@
path = tdata.path("mitmproxy/contentviews/test_js_data/" + filename)
with open(path) as f:
- input = f.read()
+ input = _soundness_check(f.read(), str)
with open("-formatted.".join(path.rsplit(".", 1))) as f:
expected = _soundness_check(f.read(), str)mitmproxy — test/mitmproxy/contentviews/test__view_wbxml.py--- base/test/mitmproxy/contentviews/test__view_wbxml.py
+++ head/test/mitmproxy/contentviews/test__view_wbxml.py
@@ -23,5 +23,5 @@
path = tdata.path(datadir + "data.wbxml")
with open(path, "rb") as f:
- input = f.read()
+ input = _soundness_check(f.read(), bytes)
with open("-formatted.".join(path.rsplit(".", 1))) as f:
expected = _soundness_check(f.read(), str)mitmproxy — test/mitmproxy/contentviews/test__view_xml_html.py--- base/test/mitmproxy/contentviews/test__view_xml_html.py
+++ head/test/mitmproxy/contentviews/test__view_xml_html.py
@@ -24,5 +24,5 @@
with open(tdata.path(datadir + "simple.html")) as f:
- input = f.read()
+ input = _soundness_check(f.read(), str)
tokens = tokenize(input)
assert str(next(tokens)) == "Tag(<!DOCTYPE html>)"
@@ -46,5 +46,5 @@
path = tdata.path(datadir + filename)
with open(path, "rb") as f:
- input = f.read()
+ input = _soundness_check(f.read(), bytes)
with open("-formatted.".join(path.rsplit(".", 1))) as f:
expected = _soundness_check(f.read(), str)mitmproxy — test/mitmproxy/io/test_tnetstring.py--- base/test/mitmproxy/io/test_tnetstring.py
+++ head/test/mitmproxy/io/test_tnetstring.py
@@ -72,7 +72,7 @@
if what == 3:
if random.randint(0, 1) == 0:
- return random.randint(0, MAXINT)
+ return random.randint(0, _soundness_check(MAXINT, int))
else:
- return -1 * random.randint(0, MAXINT)
+ return -1 * random.randint(0, _soundness_check(MAXINT, int))
n = random.randint(0, 100)
return bytes(random.randint(32, 126) for _ in range(n))
@@ -88,5 +88,5 @@
def test_roundtrip_format_random(self):
for _ in range(10):
- v = _soundness_check(get_random_object(), (list, dict, type(None), int, bytes))
+ v = get_random_object()
self.assertEqual(v, tnetstring.loads(tnetstring.dumps(v)))
self.assertEqual((v, b""), tnetstring.pop(memoryview[int](tnetstring.dumps(v))))
@@ -94,5 +94,5 @@
def test_roundtrip_format_unicode(self):
for _ in range(10):
... 297 characters elided ...
@@ -124,5 +124,5 @@
def test_roundtrip_file_random(self):
for _ in range(10):
- v = _soundness_check(get_random_object(), (list, dict, type(None), int, bytes))
+ v = get_random_object()
s = io.BytesIO()
tnetstring.dump(v, s)mitmproxy — test/mitmproxy/platform/test_pf.py--- base/test/mitmproxy/platform/test_pf.py
+++ head/test/mitmproxy/platform/test_pf.py
@@ -1,2 +1,10 @@
+def _soundness_check(_v, _t):
+ if not isinstance(_v, _t):
+ raise TypeError(
+ f"type soundness violation: expected {getattr(_t, '__name__', _t)}, "
+ f"got {type(_v).__name__}"
+ )
+ return _v
+
lazy import sys
@@ -13,5 +21,5 @@
p = tdata.path("mitmproxy/data/pf01")
with open(p, "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)mitmproxy — test/mitmproxy/test_certs.py--- base/test/mitmproxy/test_certs.py
+++ head/test/mitmproxy/test_certs.py
@@ -285,5 +285,5 @@
def test_simple(self, tdata):
with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
c1 = certs.Cert.from_pem(d)
assert c1.cn == "google.com"
@@ -332,5 +332,5 @@
def test_convert(self, tdata):
with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
c = certs.Cert.from_pem(d)
@@ -352,5 +352,5 @@
def test_keyinfo(self, tdata, filename, name, bits):
with open(tdata.path(f"mitmproxy/net/data/{filename}"), "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
c = certs.Cert.from_pem(d)
assert c.keyinfo == (name, bits)
@@ -371,5 +371,5 @@
def test_err_broken_sans(self, tdata):
with open(tdata.path("mitmproxy/net/data/text_cert_weird1"), "rb") as f:
- d = f.read()
... 352 characters elided ...
c = certs.Cert.from_pem(d)
@@ -472,5 +472,5 @@
def test_special_character(self, tdata):
with open(tdata.path("mitmproxy/net/data/text_cert_with_comma"), "rb") as f:
- d = f.read()
+ d = _soundness_check(f.read(), bytes)
c = certs.Cert.from_pem(d)mongo-python-driver — test/asynchronous/test_dns.py--- base/test/asynchronous/test_dns.py
+++ head/test/asynchronous/test_dns.py
@@ -48,4 +48,8 @@
)
return _v
+
+def _soundness_iter(_it, _t):
+ for _x in _it:
+ yield _soundness_check(_x, _t)
@@ -209,6 +213,6 @@
def create_tests(cls):
- for filename in _soundness_check(glob.glob(os.path.join(cls.TEST_PATH, "*.json")), list):
- test_suffix, _ = _soundness_check(os.path.splitext(os.path.basename(filename)), tuple)
+ for filename in _soundness_iter(_soundness_check(glob.glob(os.path.join(cls.TEST_PATH, "*.json")), list), str):
+ test_suffix, _ = _soundness_check(os.path.splitext(_soundness_check(os.path.basename(filename), str)), tuple)
with open(filename) as dns_test_file:
test_method = create_test(json.load(dns_test_file))mongo-python-driver — test/asynchronous/test_sdam_monitoring_spec.py--- base/test/asynchronous/test_sdam_monitoring_spec.py
+++ head/test/asynchronous/test_sdam_monitoring_spec.py
@@ -238,7 +238,7 @@
# The order of ServerOpening/ClosedEvents doesn't matter
if isinstance(result, (monitoring.ServerOpeningEvent, monitoring.ServerClosedEvent)):
- i, passed, message = _soundness_check(compare_multiple_events(
+ i, passed, message = compare_multiple_events(
i, expected_results, self.all_listener.results
- ), tuple)
+ )
self.assertTrue(passed, message)
else:mongo-python-driver — test/asynchronous/test_server_selection_in_window.py--- base/test/asynchronous/test_server_selection_in_window.py
+++ head/test/asynchronous/test_server_selection_in_window.py
@@ -142,5 +142,5 @@
nodes = client.nodes
self.assertEqual(len(nodes), 2)
- freqs = dict.fromkeys(nodes, 0.0)
+ freqs = _soundness_check(dict.fromkeys(nodes, 0.0), dict)
for event in events:
freqs[event.connection_id] += 1mongo-python-driver — test/test_dns.py--- base/test/test_dns.py
+++ head/test/test_dns.py
@@ -48,4 +48,8 @@
)
return _v
+
+def _soundness_iter(_it, _t):
+ for _x in _it:
+ yield _soundness_check(_x, _t)
@@ -207,6 +211,6 @@
def create_tests(cls):
- for filename in _soundness_check(glob.glob(os.path.join(cls.TEST_PATH, "*.json")), list):
- test_suffix, _ = _soundness_check(os.path.splitext(os.path.basename(filename)), tuple)
+ for filename in _soundness_iter(_soundness_check(glob.glob(os.path.join(cls.TEST_PATH, "*.json")), list), str):
+ test_suffix, _ = _soundness_check(os.path.splitext(_soundness_check(os.path.basename(filename), str)), tuple)
with open(filename) as dns_test_file:
test_method = create_test(json.load(dns_test_file))mongo-python-driver — test/test_sdam_monitoring_spec.py--- base/test/test_sdam_monitoring_spec.py
+++ head/test/test_sdam_monitoring_spec.py
@@ -238,7 +238,7 @@
# The order of ServerOpening/ClosedEvents doesn't matter
if isinstance(result, (monitoring.ServerOpeningEvent, monitoring.ServerClosedEvent)):
- i, passed, message = _soundness_check(compare_multiple_events(
+ i, passed, message = compare_multiple_events(
i, expected_results, self.all_listener.results
- ), tuple)
+ )
self.assertTrue(passed, message)
else:mongo-python-driver — test/test_server_selection_in_window.py--- base/test/test_server_selection_in_window.py
+++ head/test/test_server_selection_in_window.py
@@ -142,5 +142,5 @@
nodes = client.nodes
self.assertEqual(len(nodes), 2)
- freqs = dict.fromkeys(nodes, 0.0)
+ freqs = _soundness_check(dict.fromkeys(nodes, 0.0), dict)
for event in events:
freqs[event.connection_id] += 1mongo-python-driver — test/unified_format.py--- base/test/unified_format.py
+++ head/test/unified_format.py
@@ -1384,5 +1384,5 @@
)
- for idx, expected_event in enumerate(events):
+ for idx, expected_event in enumerate[str](events):
self.match_evaluator.match_event(expected_event, actual_events[idx])paasta — paasta_tools/cli/cmds/local_run.py--- base/paasta_tools/cli/cmds/local_run.py
+++ head/paasta_tools/cli/cmds/local_run.py
@@ -1002,7 +1002,7 @@
environment["YELP_SVC_AUTHZ_TOKEN"] = get_sso_auth_token()
- local_run_environment = get_local_run_environment_vars(
+ local_run_environment = _soundness_check(get_local_run_environment_vars(
instance_config=instance_config, port0=chosen_port, framework=framework
- )
+ ), dict)
environment.update(local_run_environment)
net = instance_config.get_net()
|
…s, and a sixth rung the native backend's correctness pass. every change here was measured against a build of the commit before it, and the numbers are in scratch.tasks.md. - an artefact built for one interpreter refuses to run under another, rather than segfaulting inside a type construction - code that never runs proves nothing: ty types unreachable code as `Never`, which is assignable to everything, so it took the first representation going - a method's decorator ran twice, because the class body had already applied it - a parameter's register covers what its own body writes, not just its default - a default is a written type, so the interpreted twin enforces it too - a package body whose package cannot be named is declined, not renamed - a union taken apart keeps knowing it was defined in terms of itself - a finished frame writes its return down, so `am_send` answers without an exception: `coro` 1.07x -> 1.77x against cpython - `isoinstance.sh`, a sixth sweep rung, reads members off the instance it built — the first rung to look past construction, and five modules differ only there
KotlinIsland
force-pushed
the
extension-modules-work
branch
from
August 20, 2026 09:52
436361e to
48ea6cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compile to a cpython extension module: the declines, the wrong answers, and a sixth rung
the native backend's correctness pass. every change here was measured against a build of the commit before it, and the numbers are in scratch.tasks.md.
Never, which is assignable to everything, so it took the first representation goingam_sendanswers without an exception:coro1.07x -> 1.77x against cpythonisoinstance.sh, a sixth sweep rung, reads members off the instance it built — the first rung to look past construction, and five modules differ only there