python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.52k stars 574 forks source link

`jsonschema._format.is_css_color_code` and `jsonschema._format.is_css21_color` never exist if the latest version of `webcolors` is installed #1268

Closed AlexWaygood closed 1 month ago

AlexWaygood commented 1 month ago

(This issue isn't a complaint, just an FYI!)

The following block of code will always raise ImportError if you have the latest version of webcolors installed, meaning that the contextlib.suppress block will always exit immediately, and these functions will never be defined; the block is now essentially dead code:

https://github.com/python-jsonschema/jsonschema/blob/0024b584c6b6f332f0f5fa5452488901b73328f9/jsonschema/_format.py#L415-L429

This is because webcolors made the CSS21_NAMES_TO_HEX constant private in webcolors==24.6.0 (released on June 6), so the statement from webcolors import CSS21_NAMES_TO_HEX now always raises ImportError. The diff between the latest version of webcolors and the release before it can be seen here: https://github.com/ubernostrum/webcolors/compare/1.13...24.6.0.

Obviously third parties should not be relying on any functions in the internal _format module, so this isn't a complaint! But we spotted this in typeshed's CI, and thought you might like to know.

Julian commented 1 month ago

Thanks! Indeed good to know, will have a look. Appreciated!

Julian commented 1 month ago

Should be fixed in the next release, thanks again.