Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

CI run against latest deps is failing #12901

Closed
github-actions bot opened this issue May 28, 2022 · 3 comments · Fixed by #12912
Closed

CI run against latest deps is failing #12901

github-actions bot opened this issue May 28, 2022 · 3 comments · Fixed by #12912

Comments

@github-actions
Copy link
Contributor

github-actions bot commented May 28, 2022

See https://github.com/matrix-org/synapse/actions/runs/2407332978

@DMRobertson
Copy link
Contributor

 synapse/config/_util.py:59: error: Subclass of "str" and "int" cannot exist: would have incompatible method signatures  [unreachable]
synapse/config/_util.py:60: error: Statement is unreachable  [unreachable]

def json_error_to_config_error(
e: jsonschema.ValidationError, config_path: Iterable[str]
) -> ConfigError:
"""Converts a json validation error to a user-readable ConfigError
Args:
e: the exception to be converted
config_path: the path within the config file. This will be used as a basis
for the error message.
Returns:
a ConfigError
"""
# copy `config_path` before modifying it.
path = list(config_path)
for p in list(e.absolute_path):
if isinstance(p, int):
path.append("<item %i>" % p)
else:
path.append(str(p))
return ConfigError(e.message, path)

I think the underlying change was the recent types-jsonschema release, see python/typeshed#7950. The stubs now say that e.absolute_path is a Sequence[str].

@DMRobertson
Copy link
Contributor

DMRobertson commented May 29, 2022

The stubs are incorrect!

import jsonschema

SCHEMA = {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "array",
    "items": {"type": "string"},
}


document = ["a", 12345, "c", "d"]

try:
    jsonschema.validate(document, SCHEMA)
except jsonschema.ValidationError as e:
    print(repr(e))
    for path_entry in e.absolute_path:
        print(repr(path_entry), type(path_entry))
python temp.py
<ValidationError: "12345 is not of type 'string'">
1 <class 'int'>

@DMRobertson
Copy link
Contributor

Proposed a fix upstream at python/typeshed#7980

DMRobertson pushed a commit that referenced this issue May 29, 2022
Fixes #12901 by incoprating python/typeshed#7980

(The olddeps will automatically be fixed now, but let's pull in the more
complete stubs for day-to-day use while we're at it.)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant