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

#1121 Deprecate debug parameter of make_handler() #1123

Merged

Conversation

f0t0n
Copy link
Contributor

@f0t0n f0t0n commented Aug 25, 2016

What do these changes do?

  • Deprecate debug parameter of Application.make_handler
  • Add docs for debug parameter in the Application's constructor
  • Fix docs display for Application's loop parameter
  • Add docs for Application.debug attribute
  • Add a note about the deprecation of the debug parameter for
    Application.make_handler()

Are there changes in behavior for the user?

From now Application.make_handler will use application's debug mode.
If debug parameter is passed to this method and differs with the value of Application.debug,
the ValueError will be raised.

Related issue number

#1121

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@f0t0n
Copy link
Contributor Author

f0t0n commented Aug 25, 2016

@asvetlov Please check if this reflects your vision.

Tests are coming soon.

@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch 2 times, most recently from 6a20fcf to 172be9a Compare August 25, 2016 18:57
@codecov-io
Copy link

codecov-io commented Aug 25, 2016

Current coverage is 98.17% (diff: 100%)

Merging #1123 into master will increase coverage by <.01%

@@             master      #1123   diff @@
==========================================
  Files            28         28          
  Lines          6392       6398     +6   
  Methods           0          0          
  Messages          0          0          
  Branches       1076       1078     +2   
==========================================
+ Hits           6275       6281     +6   
  Misses           63         63          
  Partials         54         54          

Powered by Codecov. Last update bdba14f...bd5f47c

@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch from 172be9a to c20dd31 Compare August 25, 2016 22:22
@f0t0n
Copy link
Contributor Author

f0t0n commented Aug 25, 2016

Added test coverage. Ready for review.

@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch 3 times, most recently from 6017d8a to 1add498 Compare August 25, 2016 23:12
@@ -221,6 +221,22 @@ def middlewares(self):
return self._middlewares

def make_handler(self, **kwargs):
try:
debug = kwargs['debug']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer debug = kwargs.pop('debug', _sentinel)
Please use this form, it's a little shorter and faster than exception based approach.

Copy link
Contributor Author

@f0t0n f0t0n Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the issue description you said:

If app.debug conflicts with explicitly passed debug param -- raise ValueError.

So that if we put default boolean value to kwargs.pop() we can't know if the key was in the dictionary or not.
Also we want to compare this value to self.debug and raise a ValueError if they differ but only if the value was there.
Of course we can use None as a default value and then check for None.

debug = kwargs.pop('debug', None)
if debug is not None and debug != self.debug:
    raise ValueError("...")
return self._handler_factory(self, self.router, debug=self.debug, loop=self.loop, **kwargs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helpers._sentinel is a marker which could be used even if None is proper value.
Not necessary for boolean parameters though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got you. Didn't see that object before. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes you've suggested are done.

@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch 2 times, most recently from 5480568 to 02d60c9 Compare August 26, 2016 14:20
@@ -1128,6 +1135,13 @@ duplicated like one using :meth:`Application.copy`.
:param kwargs: additional parameters for :class:`RequestHandlerFactory`
constructor.

.. note::
Copy link
Member

@asvetlov asvetlov Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .. deprecated:: 1.0 directive.

Copy link
Contributor Author

@f0t0n f0t0n Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought to do this but the parameters of make_handler are not described and there're just **kwargs.
I can add debug to the method signature and debug parameter description and deprecation hint but I don't think it's good idea to add deprecated parameter to signature now (before the release which deprecates this).

If I just use .. deprecated:: 1.0 and the text to me it looks ugly and could be confusing.

image

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be confusing

Namely user may ask "what's deprecated, kwargs or make_handler method? o_O".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add identation to push deprecation directive under parameter spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done.

image

I just doubt if this could confuse user and he could briefly read this as

kwargs - additional parameters for RequestHandlerFactory constructor.

    deprecated since 1.0: (blah-blah tl;dr!)

and he thinks "ok probably those kwargs are deprecated".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best solution is explicitly document all available parameters.
It makes sense not only for getting rid of weird deprecation.
I suspect the most part of users just don't know what parameters are available.

But it's a subject for another PR.
Feel free to create it if you want.

@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch from 02d60c9 to 40741d2 Compare August 26, 2016 17:40
- Deprecate `debug` parameter of `Application.make_handler`
- Add docs for `debug` parameter in the `Application`'s constructor
- Fix docs display for `Application`'s `loop` parameter
- Add docs for `Application.debug` attribute
- Add a note about the deprecation of the `debug` parameter for
    `Application.make_handler()`
- Test make_handler debug deprecation
@f0t0n f0t0n force-pushed the feature/app-make-handler-debug-param branch from 40741d2 to bd5f47c Compare August 26, 2016 19:27
@asvetlov asvetlov merged commit f5c3416 into aio-libs:master Aug 26, 2016
@asvetlov
Copy link
Member

Thanks!

@f0t0n f0t0n deleted the feature/app-make-handler-debug-param branch August 26, 2016 22:10
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants