-
Notifications
You must be signed in to change notification settings - Fork 602
A less naive strategy for getting view closure var #306
A less naive strategy for getting view closure var #306
Conversation
what's your use case that the current implementation doesn't cover? |
I have decorated views that are not being unwrapped correctly, and thus not documented, because 0th index is not a sufficient condition in all cases. That the view argument is of FunctionType is necessarily true, and provides some flexibility. That flexibility means the difference between whether DRS actually documents the majority of my views, instead of ignoring them because of something trivial. |
Could you post an example view? I'm curious, and also I want something in the test suite for this. |
Sure. I was trying to craft a test for this on my lunch break yesterday, but the tests file is quite the behemoth and is light on the intent comments and docstrings. I will take another stab at it. |
6532413
to
cc34c08
Compare
cc34c08
to
763711b
Compare
sweetness! |
I keep getting dinged on my amended commits because I'm doing that after running tox. One sec. |
763711b
to
f029564
Compare
Pushed a linter friendly version of |
Working on the test failure now. |
f029564
to
157e97b
Compare
Fixed. I wasn't using the 2/3 compatible form of |
157e97b
to
ac9c087
Compare
your for more info link in the decorator doc doesn't seem to go anywhere? |
I see, it looks like the original branch is now gone, but I don't have a SHA to point to it. I've been using a version that was proposed in a Django ticket for years now, that code essentially comes from this patch: https://code.djangoproject.com/attachment/ticket/14512/ticket14512.diff Usually this decorator wraps other decorator invocations that are meant for decorating an FBV. I've simply unwrapped the wrapped decorator and that's where the name 'squashed' comes from. 'Unwrapped' may have been a better choice, but I didn't want to use that term because it has a slightly different (albeit similar) meaning in I've found a shorter version, here, which isn't EXACTLY the same thing but seems to be for my purposes: The tricky thing here is, the shorter version does not seem to exercise the bug because of how it's constructed. Since the scoping is a bit different when |
- Now handles views decorated with functions that have positional arguments - Searches for a types.FunctionType argument in the closure, rather than assuming the first argument is the view.
ac9c087
to
80535a2
Compare
A less naive strategy for getting view closure var
argument is the view. This is a correct implementation for existing cases as well.