Skip to content

Option to cache black configuration per-file #24

@haplo

Description

@haplo

Currently load_config is called every time the plugin is asked to format the whole document, which requires finding the root of the project the Python file to be formatted, then finding the pyproject.toml file if any and parsing it into a dictionary. A simple way to cache these results is by using lru_cache decorator on load_config, however this can confuse users as changes to their pyproject.toml files would not be visible to python-lsp-black until the LSP server is restarted. For this reason config caching should be disabled by default and only enabled via explicit configuration.

Introduce a way to configure the behavior of python-lsp-black, starting with a cache_config setting that defaults to None. When set to an integer value it will be used for the lru_cache call on load_config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions