Skip to content

Conversation

@benedwards14
Copy link
Contributor

@benedwards14 benedwards14 commented Nov 12, 2019

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

This looks like a good change to me! Just a few comments below to fix CI and clean things up.

def dec(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wraps(func)(wrapper)
Copy link
Member

Choose a reason for hiding this comment

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

I think the tests are failing because of this missing newline:

Suggested change
return wraps(func)(wrapper)
return wraps(func)(wrapper)


class ForRefExample():
@ann_module.dec
def func(a: 'ForRefExample'):
Copy link
Member

Choose a reason for hiding this comment

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

Minor, but maybe just name this argument self for cleanliness?

Suggested change
def func(a: 'ForRefExample'):
def func(self: 'ForRefExample'):


@ann_module.dec
@ann_module.dec
def nested(a: 'ForRefExample'):
Copy link
Member

Choose a reason for hiding this comment

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

See above:

Suggested change
def nested(a: 'ForRefExample'):
def nested(self: 'ForRefExample'):

self.assertEqual(gth(G), {'lst': ClassVar[List[T]]})

def test_get_type_hints_wrapped_decoratored_func(self):
expects = {'a': ForRefExample}
Copy link
Member

Choose a reason for hiding this comment

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

See above:

Suggested change
expects = {'a': ForRefExample}
expects = {'self': ForRefExample}

@brandtbucher brandtbucher added the type-bug An unexpected behavior, bug, or error label Nov 12, 2019
@brandtbucher
Copy link
Member

Thanks for the PR @benedwards14!

This one should also have a NEWS entry. Just something simple, like:

:meth:`typing.get_type_hints` properly handles functions decorated with :meth:`functors.wraps`. 

@benedwards14
Copy link
Contributor Author

benedwards14 commented Nov 21, 2019

Hey @brandtbucher, thanks for the review. Here are the markups.

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Looks good! Just a couple of remaining style nitpicks:


gth = get_type_hints

class ForRefExample():
Copy link
Member

Choose a reason for hiding this comment

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

No parentheses here, and 2 blank lines between top-level definitions:

Suggested change
class ForRefExample():
class ForRefExample:

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Sorry, one last typo I spotted. Then good!

@brandtbucher
Copy link
Member

@ilevkivskyi

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@ilevkivskyi
Copy link
Member

(Added backport labels since this is a bugfix.)

@ilevkivskyi ilevkivskyi merged commit 0aca3a3 into python:master Nov 21, 2019
@miss-islington
Copy link
Contributor

Thanks @benedwards14 for the PR, and @ilevkivskyi for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-17324 is a backport of this pull request to the 3.8 branch.

@bedevere-bot
Copy link

GH-17325 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 21, 2019
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 21, 2019
miss-islington added a commit that referenced this pull request Nov 21, 2019
miss-islington added a commit that referenced this pull request Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants