Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Inheriting collections.namedtuple and calling super(C, cls).__new__(cls, ...) results in empty analysis set #312

Closed
lostmsu opened this issue Oct 26, 2018 · 5 comments

Comments

@lostmsu
Copy link
Contributor

lostmsu commented Oct 26, 2018

Sample code:

import collections

class A(collections.namedtuple('A', [])):
  def __new__(cls):
    return super(A, cls).__new__(cls)

a = A()

Possibly related to #15, #174

lostmsu added a commit to losttech/PLS that referenced this issue Oct 26, 2018
@lostmsu
Copy link
Contributor Author

lostmsu commented Oct 26, 2018

A test can be cherry-picked from 010a67e

lostmsu added a commit to losttech/PLS that referenced this issue Oct 26, 2018
@lostmsu
Copy link
Contributor Author

lostmsu commented Oct 26, 2018

I am also unsure why in the following:

class B(object):
  def __new__(cls):
    return super(B, cls).__new__(cls)

class A(B):
  def __new__(cls):
    return super(A, cls).__new__(cls)

a = A()

a ends up possibly being either of A and B.

Initially I thought, that is because of my previous change to propagate return types, but if I comment it out, the result does not change.

@lostmsu
Copy link
Contributor Author

lostmsu commented Oct 26, 2018

I suspect a similar issue would happen to any non-specialized "built-in" class. I made a really dirty workaround for internal purposes here: 645da64

lostmsu added a commit to losttech/PLS that referenced this issue Nov 7, 2018
lostmsu added a commit to losttech/PLS that referenced this issue Nov 12, 2018
@jakebailey
Copy link
Member

I think these specific cases aren't broken now, though I'm not sure if we do anything interesting with __new__.

image

image

@lostmsu
Copy link
Contributor Author

lostmsu commented Feb 21, 2019

@jakebailey I suggest to cherry-pick the regression test still. :) 010a67e

jakebailey added a commit to jakebailey/python-language-server that referenced this issue Feb 25, 2019
jakebailey added a commit that referenced this issue Feb 25, 2019
Grabbing this test for completeness' sake.
lostmsu added a commit to losttech/PLS that referenced this issue Mar 31, 2019
jakebailey added a commit to jakebailey/python-language-server that referenced this issue Nov 1, 2019
Grabbing this test for completeness' sake.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants