-
Notifications
You must be signed in to change notification settings - Fork 49
Feature typeddict #270
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
base: main
Are you sure you want to change the base?
Feature typeddict #270
Conversation
Change-Id: I30619425e1e1e4ca43286be35a8c4a85658a8acb
include missing NO_VALUE on docstrings Change-Id: I79c4657d5ea8778e2932bae3e81725af27bbef85
Change-Id: I8cd5d4fbf7eabf03e48f5434e6c50dacd07dfd3c
Change-Id: Ib1c0a38f072676f33254a91312e7237c129850f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 1821cb9 of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change 1821cb9: https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/6081 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, left just a suggestion to dry up a bit the definition
* applied typing to other backends * standardized all backends to operate on a copy of the Dict passed in Some backends did this, others did not. Change-Id: I90084c6d0ad23d7bb9988664c2cef1a739fa3ff1
Change-Id: I4b912cfdb7fdae970bd95d418e059bb9965b5832
Ready for another review. General Concerns: Redis Backend:
test_decorator.py
dogpile/cache/util.py
Backends
I wasn't too happy with this approach, but I there is no real performance/memory hit (it happens on backend startup), and most new backends will copy/edit an existing backend - so I wanted to set a unified style to reinforce. This definitely needs review and feedback, but IMHO these upgrades to typing are helping find issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a suggestion, looks great overall to me
regarding get vs pop, in my opinion we could replace all of the with gets, but let's wait for @zzzeek opinion
dogpile/cache/backends/file.py
Outdated
|
||
def __init__(self, arguments): | ||
def __init__(self, arguments: DBMBackendArguments): | ||
_arguments = cast(Dict, arguments.copy()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this backend doesn't modify the dicy, maybe we could avoid this?
I mean it may make sense for backends that use pop, but for the other maybe not? this applies also to the other cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to standardize how all the backends work, because people will use them as reference when implementing a new one.
dogpile/cache/backends/memcached.py
Outdated
self.username = _arguments.get("username", None) | ||
self.password = _arguments.get("password", None) | ||
self.tls_context = _arguments.get("tls_context", None) | ||
_arguments_super = cast(GenericMemcachedBackendArguments, _arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't great, also considering that this method doesn't modify the argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled with it either, this was purely to appease the mypy.
.. versionadded:: 1.1.5 | ||
:param dead_timeout: Time in seconds before attempting to add a node | ||
:param hashclient_dead_timeout: Time in seconds before attempting to add a node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this require a versionchanged note in the docstring and/or backward compat property what warns on access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is just correcting a docstring error. The docstring references dead_timeout
, the code uses hashclient_dead_timeout
see main:
https://github.com/sqlalchemy/dogpile.cache/blob/main/dogpile/cache/backends/memcached.py#L610
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ok, the docs is of the dictionary not of the class attributes. got it.
I'd prefer that. IIRC, the usage of pop is a legacy behavior. these constructors once popped off the vars they didn't need, then passed the mutated dicts onto other functions (such as the redis or memcached client contructors). If that is not the case anymore, I'd love to standardize everything to whatever style you and mike prefer. that would drop the need for |
I would go for get, but let's wait for mike here |
OK, yes we can use get, but we are in a collision here. Please take a look at github.com//pull/274 which is adding tests for this functionality and also fixing the memory backend. I've asked for some changes and I'm not sure the contributor understands what I'm asking for (I want a test in test_region for all backends illustrating that backends dont mutate the parameter dictionaries). |
Let me see what I can pull together in the next 30 minutes. |
fixed valkey default for lock_sleep Change-Id: I03c80c105be4ec3b280d57f340b050b16c4d937a
I added some backend tests as while doing this, I noticed there are no tests for the redis & valkey cluster backends. I did something weird, as I wasn't sure how to pull off elegantly. when a backend is tested, I add it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work, just an additional suggestion, but it's fine as is too
Change-Id: Ib7bf3ebf825c0823e70b29b0ef5ee5f21010616a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 0680d81 of this pull request into gerrit so we can run tests and reviews and stuff
Failed to create a gerrit review, git squash against branch 'main' failed |
@jvanasco could you merge with the main branch? |
Change-Id: I4b00ec1e4faa45b204bc214099d0180c46b08145
@CaselIT Done, but there is a merge commit |
it's not an issue since gerrit will squash everything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 9eb6fc3 of this pull request into gerrit so we can run tests and reviews and stuff
Patchset 9eb6fc3 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/6081 |
im dying for either of this #270 or #274 to please put a test that is across all backends (meaning, in dogpile/cache/testing/fixtures) to assert that:
|
I implemented #1 in test_region as |
I switched the backend test from test_region to GenericBackendFixture as requested, it's in #275 as separate PR for easier comparison. I do want to note there is no exiting test coverage (in general) for redis & valkey cluster backends. that is outside the scope of this though, as it will likely require a CI setup. |
Change-Id: I90beea7da33de522de95e3e901410a5966aea024
Change-Id: I6a9b9f45ecb9c8acf6e030aacfb4ec2f28b0b689
This has been updated against main. The previously requested tests were removed as they are now unnecessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 8711197 of this pull request into gerrit so we can run tests and reviews and stuff
Patchset 8711197 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/6081 |
This is the idea for using typedicts
I also updated some typing and docstrings