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

support adding per implementation warnings for hookspecs #138

Merged
merged 1 commit into from
Apr 21, 2018

Conversation

RonnyPfannschmidt
Copy link
Member

this will be used later on in pytest to deprecate hooks we dont really use/support anymore so we can remove them in future

this can also be used to do futurewarnings for experimental hooks

@justanr
Copy link

justanr commented Apr 19, 2018

I like this a lot better than my potential proposal in #133

@RonnyPfannschmidt
Copy link
Member Author

@justanr oh, i missed that, i just created this because i need it and because deprecation is a pretty concrete topic in some way (plus its nicer if you get warnings like that) - my implementation might even be a bit too concrete ^^ i hope for due scrutiny ^^

docs/index.rst Outdated

.. code-block:: python

@hookspec(impl_warning=DeprecationWarning("oldhook is deprecated and will be removed soon"))
Copy link
Contributor

Choose a reason for hiding this comment

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

What about just warning?
I don't know that the impl_ adds anything useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

warning alone is a overly generic name, thats why i added the impl in front - im happy about picking a more specific name thats describing what is happening, im severely opposed to going for a more generic name

its probably a good idea to brainstorm a better name, its fine if its a bit longer

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be general but it's as specific as the code you've written.

The type of warning is handed into the decorator and the underlying code merely uses the warnings mod to warn. Unless you intend to limit to specific subset of warning categories (which doesn't seem all that likely nor easy to describe in a variable name) I don't see how it can be more specific.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tgoodlet im not talking about types or calls - im talking about the intent of the value passed - which is a warning that is given for each implementation of the hook encountered - its bad style to encode types, its good style to enode intent

Copy link
Contributor

@goodboy goodboy Apr 19, 2018

Choose a reason for hiding this comment

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

Ok what about warning_on_call or warning_when_called?

I still think it's implicit that the warning is to be emitted at some point in the hook's lifetime and trying cram a more specific description in the variable name seems unnatural.

Copy link
Member Author

Choose a reason for hiding this comment

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

the warnings are happening at registration time, not invocation time, so on call would be wrong

warning_on_impl or warning_on_implementation might be more to the point tho

Copy link
Contributor

@goodboy goodboy Apr 19, 2018

Choose a reason for hiding this comment

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

warning_on_register?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll sleep a night over it and see what the impression is

Copy link
Member Author

Choose a reason for hiding this comment

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

i decided to call it warn_on_impl since we consistently use impl as shortcut for implementation

@goodboy
Copy link
Contributor

goodboy commented Apr 19, 2018

Looks mostly fine to me @RonnyPfannschmidt other then a nitpick at the name.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

LGTM as well! 👍

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.

4 participants