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

Conversation

@CTrando
Copy link
Contributor

@CTrando CTrando commented Jul 15, 2019

Fixes #1278

Try number 2.

Test Plan:

Diagnostic

  • Inheriting a variable that is a constant

  • Inheriting a constant

  • Inheriting a function

  • Inheriting a method

  • Inheriting an object instance

  • Inheriting a property that returns a constant

  • Inheriting a property that returns a function

  • Inheriting a property that returns a method

No Diagnostic

  • Builltin types

  • Renamed builin types

  • User Class

  • A property that returns nothing

@jakebailey
Copy link
Member

A question, what would the diagnostics be for something like this?

X = 123

class Foo(X):
   pass

class Bar(Foo):
   pass

Is it going to complain at both Foo and Bar, or just Foo? I'm thinking about the case where we get this wrong in one place, and it infects an inheritance tree. (Particularly for classes that come from mis-analyzed libraries or similar.)

@CTrando
Copy link
Contributor Author

CTrando commented Jul 16, 2019

A question, what would the diagnostics be for something like this?

X = 123

class Foo(X):
   pass

class Bar(Foo):
   pass

Is it going to complain at both Foo and Bar, or just Foo? I'm thinking about the case where we get this wrong in one place, and it infects an inheritance tree. (Particularly for classes that come from mis-analyzed libraries or similar.)

Just tested it. It only complains at Foo. It will only complain about a direct inheritance, not a chain.

@jakebailey
Copy link
Member

Perfect, but would you mind adding a test for it so we don't regress later on? (And fix the merge conflicts). Then this should be good.

@CTrando
Copy link
Contributor Author

CTrando commented Jul 16, 2019

Sorry, just haven't pushed test yet.

@CTrando CTrando merged commit c88754b into microsoft:master Jul 18, 2019
jakebailey pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
…icrosoft#1337)

* When creating a class, give diagnostic if bases are not class types
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When class inherits from something that is not a class, give a diagnostic error

3 participants