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

lru_cache variable_names_blacklist_from() logic function #1133

Merged
merged 3 commits into from
Feb 3, 2020

Conversation

skarzi
Copy link
Collaborator

@skarzi skarzi commented Feb 2, 2020

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

Closes #1130

To make using lru_cache decorator on variable_names_blacklist_from() possible - _ValidatedOptions has to be hashable, which implies its immutability (I've used attrs frozen argument) that btw is really expected in this case, because configuration options shouldn't be changed after they are loaded and validated.
This change also required updating ConfigurationOptions protocol - all attributes need to be unsettable, because _ValidatedOptions is now frozen/immutable.

If you dislike current solution (personally I don't like new definition of ConfigurationOptions protocol, however according to few issues I have found on mypy repo, it's the only way to define unsettable protocol's attributes) we can change current implementation of variable_names_blacklist_from() a bit, so it will accept allowed_domain_names and forbidden_domain_names immutable arguments instead of _ValidatedOptions, however then _ValidatedOptions will be defined as mutable.


🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

@coveralls
Copy link

coveralls commented Feb 2, 2020

Pull Request Test Coverage Report for Build 2532

  • 69 of 69 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2530: 0.0%
Covered Lines: 5106
Relevant Lines: 5106

💛 - Coveralls

@skarzi skarzi changed the title lru_cache variable_names_blacklist_from() logic function lru_cache variable_names_blacklist_from() logic function Feb 2, 2020
@sobolevn
Copy link
Member

sobolevn commented Feb 3, 2020

Thanks a lot! This is cool!

Do you think that there are possibly other places where caching can be applied?

@sobolevn sobolevn merged commit 398f5be into wemake-services:master Feb 3, 2020
@skarzi
Copy link
Collaborator Author

skarzi commented Feb 3, 2020

Do you think that there are possibly other places where caching can be applied?

I haven't found anything else after quick look on logic/ and visitors/ modules.
But I will remember about checking that during new features/fixes implementation 👍

@skarzi skarzi deleted the issue-1130 branch February 3, 2020 15:58
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 this pull request may close these issues.

cache all things dependent on configuration options
3 participants