You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constructor defined after classmethod is considered to have no args in the classmethod #1727
example3.py: note: In member "example" of class "Example":
example3.py:7: error: Unexpected keyword argument "arg1" for "Example"
example3.py:7: error: Unexpected keyword argument "arg2" for "Example"
But passes checks if __init__ is moved before the classmethod.
Adding reveal_type with the __init__ method last shows: example3.py:7: error: Revealed type is 'def () -> example3.Example'
And with __init__ first: example3.py:11: error: Revealed type is 'def (arg1: builtins.float, arg2: builtins.str) -> example3.Example'
There probably isn't any particular reason why this hasn't been fixed -- other than there being a lot of other high-priority work as well.
This doesn't sound like it would be very hard to fix (but probably not entirely trivial either). The core team is planning to allocate a block of time focused on fixing high-priority bugs in the next couple of months, and hopefully this gets fixed then.
@msullivan There is an existing PR. Please take a look at the questions that appeared there (interactions with fine-grained mode, plugins, forward references, generics, and overloads).
Activity
rzimmerman commentedon Sep 5, 2016
Probably related:
Reports:
But passes checks if
__init__is moved before the classmethod.Adding
reveal_typewith the__init__method last shows:example3.py:7: error: Revealed type is 'def () -> example3.Example'And with
__init__first:example3.py:11: error: Revealed type is 'def (arg1: builtins.float, arg2: builtins.str) -> example3.Example'ilevkivskyi commentedon Aug 7, 2017
(Raising priority to normal, since this have been reported twice after the original issue.)
Lordnibbler commentedon Aug 7, 2017
+1 on this, thanks @ilevkivskyi
matthewgrossman commentedon Aug 9, 2017
+1, this is also affecting my work
mckaysalisbury commentedon Nov 30, 2017
Yeah, my behavior shows that it sometimes works in the wrong order. (see #4290)
JelleZijlstra commentedon Dec 5, 2017
Bumping to high-pri because this is happening frequently and the workaround is non-obvious (see #2324).
2 remaining items
JukkaL commentedon Aug 16, 2018
There probably isn't any particular reason why this hasn't been fixed -- other than there being a lot of other high-priority work as well.
This doesn't sound like it would be very hard to fix (but probably not entirely trivial either). The core team is planning to allocate a block of time focused on fixing high-priority bugs in the next couple of months, and hopefully this gets fixed then.
Fixes python#1727: constructor after classmethod counts
VadimPushtaev commentedon Aug 18, 2018
I've spent some time trying to find a solution, and here is my attempt: #5501
Fixes python#1727: constructor after classmethod counts
python#1727: deps.test for classmethod
python#1727: fine-grained.test for classmethod
python#1727: more unit tests
python#1727: test classmethod in nested class
msullivan commentedon Sep 19, 2018
I've got a PR about to go up that fixes this as a side effect of changing the type of classmethod first arguments to be a
TypeTypeilevkivskyi commentedon Sep 19, 2018
@msullivan There is an existing PR. Please take a look at the questions that appeared there (interactions with fine-grained mode, plugins, forward references, generics, and overloads).
ilevkivskyi commentedon Sep 19, 2018
@msullivan Forgot to add the PR number, here it is #5501
Make classmethod's first argument be Type[...]
Make classmethod's first argument be Type[...] (#5646)