Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize annotations with python/typeshed#8608 #1027

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Dec 7, 2022

  1. Harmonize annotations with python/typeshed#8608

    python/typeshed#8608 introduced annotations for `create` which are not
    fully reflected here.
    
    In order to reflect that state into `jsonschema`, a new module,
    `jsonschema._typing` is introduced. The purpose of `_typing` is to be
    a singular place for the library to define type aliases and any
    typing-related utilities which may be needed. This will let us use
    aliases like `_typing.JsonValue` in many locations where any valid
    JSON datatype is accepted.
    The definitions can be refined over time as necessary.
    
    Initial definitions in `_typing` are:
    - Schema (any JSON object)
    - JsonObject (any JSON object)
    - JsonValue (any JSON value, including objects or sequences)
    
    `Schema` is just another name for `JsonObject`. Perhaps it is not
    needed, but the name may help clarify things to a reader. It is not
    obvious at present whether or not it is a good or bad idea to notate
    it as such, but a similar Schema alias is defined in typeshed and
    seems to be working there to annotate things accurately.
    
    These types are using `Mapping` and `Sequence` rather than `dict` or
    `list`. The rationale is that `jsonschema`'s logic does not dictate
    that the objects used *must* be defined in stdlib types or subtypes
    thereof. For example, a `collections.UserDict` could be used and
    should be accepted by the library (`UserDict` wraps but does not
    inherit from `dict`.)
    sirosen committed Dec 7, 2022
    Configuration menu
    Copy the full SHA
    7cfa790 View commit details
    Browse the repository at this point in the history