Home / Class/ TagDict Class — flask Architecture

TagDict Class — flask Architecture

Architecture documentation for the TagDict class in tag.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab["TagDict"]
  a0222544_1c8a_9b62_d419_e9d66bd3544a["JSONTag"]
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab -->|extends| a0222544_1c8a_9b62_d419_e9d66bd3544a
  5e2eed77_f23f_513d_2d00_d39ce63b14ab["tag.py"]
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab -->|defined in| 5e2eed77_f23f_513d_2d00_d39ce63b14ab
  0c7c2db6_8b2b_9460_6579_8bc88612c134["check()"]
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab -->|method| 0c7c2db6_8b2b_9460_6579_8bc88612c134
  155c4f22_8e39_11bb_246d_5cae142afbc9["to_json()"]
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab -->|method| 155c4f22_8e39_11bb_246d_5cae142afbc9
  ff1bead0_bf71_d69b_ec9c_51bb845bfa80["to_python()"]
  23ab0d6d_1974_f1de_8d96_ad5fc53532ab -->|method| ff1bead0_bf71_d69b_ec9c_51bb845bfa80

Relationship Graph

Source Code

src/flask/json/tag.py lines 93–116

class TagDict(JSONTag):
    """Tag for 1-item dicts whose only key matches a registered tag.

    Internally, the dict key is suffixed with `__`, and the suffix is removed
    when deserializing.
    """

    __slots__ = ()
    key = " di"

    def check(self, value: t.Any) -> bool:
        return (
            isinstance(value, dict)
            and len(value) == 1
            and next(iter(value)) in self.serializer.tags
        )

    def to_json(self, value: t.Any) -> t.Any:
        key = next(iter(value))
        return {f"{key}__": self.serializer.tag(value[key])}

    def to_python(self, value: t.Any) -> t.Any:
        key = next(iter(value))
        return {key[:-2]: value[key]}

Domain

Extends

Frequently Asked Questions

What is the TagDict class?
TagDict is a class in the flask codebase, defined in src/flask/json/tag.py.
Where is TagDict defined?
TagDict is defined in src/flask/json/tag.py at line 93.
What does TagDict extend?
TagDict extends JSONTag.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free