Home / File/ config.py — flask Source File

config.py — flask Source File

Architecture documentation for config.py, a python file in the flask codebase. 8 imports, 1 dependents.

File python ApplicationCore Scaffolding 8 imports 1 dependents 1 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  2e858a02_7725_54fd_8d55_a9c969ab89bf["config.py"]
  0bdbbb6d_41ac_cb65_54a5_10ce0159c2d6["sansio.app"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> 0bdbbb6d_41ac_cb65_54a5_10ce0159c2d6
  bc9ed0cc_51ba_2320_6e8b_553a52c4f833["errno"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> bc9ed0cc_51ba_2320_6e8b_553a52c4f833
  a2a0fafc_2ea9_1b29_60c7_bc4419008a44["__init__.py"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> a2a0fafc_2ea9_1b29_60c7_bc4419008a44
  bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e
  27bc050a_0167_5d02_546e_7c5efffc737b["types"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> 27bc050a_0167_5d02_546e_7c5efffc737b
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  d04b8dfd_bc0a_e096_b08f_f16e74bf9488["werkzeug.utils"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> d04b8dfd_bc0a_e096_b08f_f16e74bf9488
  151f2031_7088_18d5_0dfa_595db91e8495["typing_extensions"]
  2e858a02_7725_54fd_8d55_a9c969ab89bf --> 151f2031_7088_18d5_0dfa_595db91e8495
  e1ae29a1_73d3_d5e9_3fd5_548f4ac50138["__init__.py"]
  e1ae29a1_73d3_d5e9_3fd5_548f4ac50138 --> 2e858a02_7725_54fd_8d55_a9c969ab89bf
  style 2e858a02_7725_54fd_8d55_a9c969ab89bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import errno
import json
import os
import types
import typing as t

from werkzeug.utils import import_string

if t.TYPE_CHECKING:
    import typing_extensions as te

    from .sansio.app import App


T = t.TypeVar("T")


class ConfigAttribute(t.Generic[T]):
    """Makes an attribute forward to the config"""

    def __init__(
        self, name: str, get_converter: t.Callable[[t.Any], T] | None = None
    ) -> None:
        self.__name__ = name
        self.get_converter = get_converter

    @t.overload
    def __get__(self, obj: None, owner: None) -> te.Self: ...

    @t.overload
    def __get__(self, obj: App, owner: type[App]) -> T: ...

    def __get__(self, obj: App | None, owner: type[App] | None = None) -> T | te.Self:
        if obj is None:
            return self

        rv = obj.config[self.__name__]

        if self.get_converter is not None:
            rv = self.get_converter(rv)

        return rv  # type: ignore[no-any-return]

    def __set__(self, obj: App, value: t.Any) -> None:
        obj.config[self.__name__] = value


class Config(dict):  # type: ignore[type-arg]
    """Works exactly like a dict but provides ways to fill it from files
    or special dictionaries.  There are two common patterns to populate the
    config.

    Either you can fill the config from a config file::

        app.config.from_pyfile('yourconfig.cfg')

    Or alternatively you can define the configuration options in the
    module that calls :meth:`from_object` or provide an import path to
// ... (308 more lines)

Subdomains

Dependencies

Imported By

Frequently Asked Questions

What does config.py do?
config.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, Scaffolding subdomain.
What functions are defined in config.py?
config.py defines 1 function(s): typing_extensions.
What does config.py depend on?
config.py imports 8 module(s): __init__.py, errno, os, sansio.app, types, typing.py, typing_extensions, werkzeug.utils.
What files import config.py?
config.py is imported by 1 file(s): __init__.py.
Where is config.py in the architecture?
config.py is located at src/flask/config.py (domain: ApplicationCore, subdomain: Scaffolding, directory: src/flask).

Analyze Your Own Codebase

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

Try Supermodel Free