-
Notifications
You must be signed in to change notification settings - Fork 79
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
feat: allow Requests to be sent to exempt_when #160
Conversation
+1 Today we return This PR would enable us to use |
@laurentS anything else you want to see here for this to be mergeable? |
@colin99d thanks for submitting this PR! I just took a quick look, but I saw the PR changes the arguments to a method that's probably public, which means it would probably break some users' code (at least their typechecks would complain). Can the extra arg be made optional to avoid that? |
@laurentS im so sorry I just sorry your comment, changes added!!! |
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.
Added a suggestion to avoid inspecting on each request! Also would be worth adding a test perhaps with the example you gave in the PR description i reckon!
@laurentS anything else you want to see before this is merged? |
Co-authored-by: Reuben Thomas-Davis <[email protected]>
Also, I got a little carried away and switch from Flake8 to Ruff. Its pretty much Flake8 but way better in every way. |
Maybe we should try to do one thing per PR. Let's focus this one on the feature you initially proposed, and we can add |
I reverted ruff changes. All tests fail because of this line: |
It just needs reformatting. Can you run It should probably look like this: self._exempt_when_takes_request = (
len(inspect.signature(self.exempt_when).parameters) == 1
) |
Not related to this PR but maybe we could implement pre-commit on the repo, so that anyone wanting to contribute would just need to do one |
@laurentS changes in, can we merge now? |
@laurentS are we waiting on anything else here? |
I think CI checks should be green before merging :) Logs seem to have been removed by github, but I think there was something pretty clear in there as to what needs fixing. |
Can you please rerun them so I can see what it is? |
I can't seem to rerun CI on github, weird. I pulled your changes locally, try |
@laurentS done! |
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.
Nice! My only comment is that is_exempt
is not a property anymore, so it would be good to add a note about breaking changes due to this, as it's bound to break somebody else's code.
Ok, where would you like the note added? |
@laurentS yeah just let me know exactly where you want this note added so we can get this merged. |
Yes, the changelog is a good place for that. If you make sure to include "breaking change" in the wording, it'll probably help users as well. Thanks for your contribution! |
@laurentS done! |
Looks great! think adding some usage docs here Line 807 in 6547679
slowapi/tests/test_starlette_extension.py Line 195 in 6547679
|
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.
Looks good to me! Merging. Thanks for your patience with getting this done :)
@laurentS any plans to publish a new version to Pypi with this change (and a few others that have landed since the v0.1.9 release from February)? |
@ecly I maintain |
Creates a way to use the request object in the exempt_when function.
Now allows functions like this to be used:
Fixes #155
Lines 702 and 706 were automatically removed by my linter because they are unused. Let me know if you want them back. Also, let me know if you want ruff added to CI for code linting.