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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not cache configuration files #1994

Closed
kaste opened this issue Nov 11, 2022 · 0 comments · Fixed by #1995
Closed

Do not cache configuration files #1994

kaste opened this issue Nov 11, 2022 · 0 comments · Fixed by #1995

Comments

@kaste
Copy link
Contributor

kaste commented Nov 11, 2022

isort can run in long processes when used in an editor. In that
scenario users might edit their configuration files and literally
save a file again to see its outcome.

This is not possible right now because we lru_cache() all the
relevant functions in settings.py.

It is strange that we do this in the first place as we either collect
all known configs using the Trie implementation or we only
construct exactly one Config object based on the first file name,
the working dir, or from settings_path|file...

We can probably remove the caches in settings.py completely.
Except of course you explicitly wanted to optimize for long
running processes.

kaste added a commit to kaste/isort that referenced this issue Nov 11, 2022
Fixes PyCQA#1994

isort can run in long processes when used in an editor.  In that
scenario it is confusing for users when editing a configuration file
does not change isorts outcome.

Remove the caches in `settings.py` completely to re-read the
configuration on each run.

This is safe for the CLI case as we here either use the `Trie`
implementation which collects all known configuration files beforehand,
or we exactly construct one `Config` object based on the first filename,
the working dir, or the explicit `settings_path|file` settings.

Not caching is therefore more efficient for the CLI case and more
useful for the editor case.
kaste added a commit to kaste/isort that referenced this issue Feb 8, 2023
Fixes PyCQA#1994

isort can run in long processes when used in an editor.  In that
scenario it is confusing for users when editing a configuration file
does not change isorts outcome.

Remove the caches in `settings.py` completely to re-read the
configuration on each run.

This is safe for the CLI case as we here either use the `Trie`
implementation which collects all known configuration files beforehand,
or we exactly construct one `Config` object based on the first filename,
the working dir, or the explicit `settings_path|file` settings.

Not caching is therefore more efficient for the CLI case and more
useful for the editor case.
kaste added a commit to kaste/isort that referenced this issue Feb 8, 2023
Fixes PyCQA#1994

isort can run in long processes when used in an editor.  In that
scenario it is confusing for users when editing a configuration file
does not change isorts outcome.

Remove the caches in `settings.py` completely to re-read the
configuration on each run.

This is safe for the CLI case as we here either use the `Trie`
implementation which collects all known configuration files beforehand,
or we exactly construct one `Config` object based on the first filename,
the working dir, or the explicit `settings_path|file` settings.

Not caching is therefore more efficient for the CLI case and more
useful for the editor case.
kaste added a commit to kaste/isort that referenced this issue Feb 8, 2023
Fixes PyCQA#1994

isort can run in long processes when used in an editor.  In that
scenario it is confusing for users when editing a configuration file
does not change isorts outcome.

Remove the caches in `settings.py` completely to re-read the
configuration on each run.

This is safe for the CLI case as we here either use the `Trie`
implementation which collects all known configuration files beforehand,
or we exactly construct one `Config` object based on the first filename,
the working dir, or the explicit `settings_path|file` settings.

Not caching is therefore more efficient for the CLI case and more
useful for the editor case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant