(
    schema,
    named_schemas=None,
    *,
    expand=False,
    _write_hint=True,
    _force=False,
)
Returns a parsed avro schema

    It is not necessary to call parse_schema but doing so and saving the parsed
    schema for use later will make future operations faster as the schema will
    not need to be reparsed.

    Parameters
    ----------
    schema: dict
        Input schema
    named_schemas: dict
        Dictionary of named schemas to their schema definition
    expand: bool
        If true, named schemas will be fully expanded to their true schemas
        rather than being represented as just the name. This format should be
        considered an output only and not passed in to other reader/writer
        functions as it does not conform to the avro specification and will
        likely cause an exception
    _write_hint: bool
        Internal API argument specifying whether or not the __fastavro_parsed
        marker should be added to the schema
    _force: bool
        Internal API argument. If True, the schema will always be parsed even
        if it has been parsed and has the __fastavro_parsed marker


    Example::

        from fastavro import parse_schema
        from fastavro import writer

        parsed_schema = parse_schema(original_schema)
        with open('weather.avro', 'wb') as out:
            writer(out, parsed_schema, records)


    Sometimes you might have two schemas where one schema references another.
    For the sake of example, let's assume you have a `Parent` schema that
    references a `Child` schema`. If you were to try to parse the parent schema
    on its own, you would get an exception because the child schema isn't
    defined. To accomodate this, we can use the `named_schemas` argument to pass
    a shared dictionary when parsing both of the schemas. The dictionary will
    get populated with the necessary schema references to make parsing possible.
    For example::

        from fastavro import parse_schema

        named_schemas = {}
        parsed_child = parse_schema(child_schema, named_schemas)
        parsed_parent = parse_schema(parent_schema, named_schemas)
Returns a parsed avro schema
Returns a parsed avro schema
def parse_schema(
    schema,
    named_schemas=None,
    *,
    expand=False,
    _write_hint=True,
    _force=False,
):
    """Returns a parsed avro schema

    It is not necessary to call parse_schema but doing so and saving the parsed
    schema for use later will make future operations faster as the schema will
    not need to be reparsed.

    Parameters
    ----------
    schema: dict
        Input schema
    named_schemas: dict
        Dictionary of named schemas to their schema definition
    expand: bool
        If true, named schemas will be fully expanded to their true schemas
        rather than being represented as just the name. This format should be
        considered an output only and not passed in to other reader/writer
        functions as it does not conform to the avro specification and will
        likely cause an exception
    _write_hint: bool
        Internal API argument specifying whether or not the __fastavro_parsed
        marker should be added to the schema
    _force: bool
        Internal API argument. If True, the schema will always be parsed even
        if it has been parsed and has the __fastavro_parsed marker


    Example::

        from fastavro import parse_schema
        from fastavro import writer

        parsed_schema = parse_schema(original_schema)
        with open('weather.avro', 'wb') as out:
            writer(out, parsed_schema, records)


    Sometimes you might have two schemas where one schema references another.
    For the sake of example, let's assume you have a `Parent` schema that
    references a `Child` schema`. If you were to try to parse the parent schema
    on its own, you would get an exception because the child schema isn't
    defined. To accomodate this, we can use the `named_schemas` argument to pass
    a shared dictionary when parsing both of the schemas. The dictionary will
    get populated with the necessary schema references to make parsing possible.
    For example::

        from fastavro import parse_schema

        named_schemas = {}
        parsed_child = parse_schema(child_schema, named_schemas)
        parsed_parent = parse_schema(parent_schema, named_schemas)
    """
    if named_schemas is None:
        named_schemas = {}

    if isinstance(schema, dict) and "__fastavro_parsed" in schema:
        if "__named_schemas" in schema:
            for key, value in schema["__named_schemas"].items():
                named_schemas[key] = value
        else:
            # Some old schemas might only have __fastavro_parsed and not
            # __named_schemas since that came later. For these schemas, we need
            # to re-parse the schema to handle named types
            return _parse_schema(schema, "", expand, _write_hint, set(), named_schemas)

    if _force or expand:
        return _parse_schema(schema, "", expand, _write_hint, set(), named_schemas)
    elif isinstance(schema, dict) and "__fastavro_parsed" in schema:
        return schema
    elif isinstance(schema, list):
        # If we are given a list we should make sure that the immediate sub
        # schemas have the hint in them
        return [
            parse_schema(
                s, named_schemas, expand=expand, _write_hint=_write_hint, _force=_force
            )
            for s in schema
        ]
    else:
        return _parse_schema(schema, "", expand, _write_hint, set(), named_schemas)
def parse_schema ( schema , named_schemas = None , * , expand = False , _write_hint = True , _force = False , ) : if named_schemas is None : named_schemas = { } if isinstance ( schema , dict ) and "__fastavro_parsed" in schema : if "__named_schemas" in schema : for key , value in schema [ "__named_schemas" ] . items ( ) : named_schemas [ key ] = value else : # Some old schemas might only have __fastavro_parsed and not # __named_schemas since that came later. For these schemas, we need # to re-parse the schema to handle named types return _parse_schema ( schema , "" , expand , _write_hint , set ( ) , named_schemas ) if _force or expand : return _parse_schema ( schema , "" , expand , _write_hint , set ( ) , named_schemas ) elif isinstance ( schema , dict ) and "__fastavro_parsed" in schema : return schema elif isinstance ( schema , list ) : # If we are given a list we should make sure that the immediate sub # schemas have the hint in them return [ parse_schema ( s , named_schemas , expand = expand , _write_hint = _write_hint , _force = _force ) for s in schema ] else : return _parse_schema ( schema , "" , expand , _write_hint , set ( ) , named_schemas )