keleshev / schema

Schema validation just got Pythonic
MIT License
2.86k stars 214 forks source link

Schema appears to be broken for Python3.8 #315

Closed Zeitsperre closed 3 months ago

Zeitsperre commented 3 months ago

It seems as though the latest release doesn't support Python3.8:

...
 miranda/decode/_decoder.py:30: in <module>
    from miranda.validators import FACETS_SCHEMA  # noqa
miranda/validators.py:82: in <module>
    Optional("date"): Or(Regex(BASIC_DT_VALIDATION, flags=re.I), "fx"),
.tox/py38-pyston/lib/python3.8/site-packages/schema.py:248: in __init__
    Regex.NAMES[i] for i, f in enumerate(f"{flags:09b}") if f != "0"
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/enum.py:733: in __format__
    return cls.__format__(val, format_spec)
E   ValueError: Unknown format code 'b' for object of type 'str'
mutricyl commented 3 months ago

Regex flag argument is expecting an integer. Can you try forcing it : Optional("date"): Or(Regex(BASIC_DT_VALIDATION, flags=int(re.I)), "fx"),

Zeitsperre commented 3 months ago

That seems to have done the trick. I imagine it's just a backwards-compatibility issue.

Zeitsperre commented 3 months ago

Thanks!