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

Expected class type but received "DeclarativeMeta" #360

Closed
Cdayz opened this issue Sep 11, 2020 · 4 comments
Closed

Expected class type but received "DeclarativeMeta" #360

Cdayz opened this issue Sep 11, 2020 · 4 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@Cdayz
Copy link

Cdayz commented Sep 11, 2020

Sorry for my awful english.

Environment data

  • Language Server version: 2020.9.4 (pyright 9983747f)
  • OS and version: Ubuntu 20.04
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.3, pyenv

Expected behaviour

No type errors, because in that case i am use DelcarativeBase metaclass for create sqlalchemy model

Actual behaviour

Pylance threat a class created from a metaclass as not a class
2020-09-11_14-34
2020-09-11_14-34_1

@erictraut
Copy link
Contributor

Thank you for reporting this problem. Pylance was not correctly handling the case where a class was created by directly instantiating a metaclass. Most libraries use the "metaclass hook" to statically declare new classes based on a metaclass, but sqlalchemy is doing something more dynamic here. I've added code to Pyright (the type checker used by Pylance) to handle this case, and the fix will be in the next release of Pylance.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 13, 2020
@github-actions github-actions bot removed the triage label Sep 13, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.5, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202095-16-september-2020

@Distortedlogic
Copy link

I am still receiving this error
06-10-2020-07-22-28

@erictraut
Copy link
Contributor

@Distortedlogic, can you please file a new issue and provide more context — preferably a short snippet of self-contained code that repros the problem? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants