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

(python): pylance type check error #2877

Closed
Glyphack opened this issue Jun 8, 2021 · 5 comments
Closed

(python): pylance type check error #2877

Glyphack opened this issue Jun 8, 2021 · 5 comments
Labels
bug This issue is a bug. language/python Related to Python bindings module/jsii Issues affecting the `jsii` module. p2

Comments

@Glyphack
Copy link

Glyphack commented Jun 8, 2021

In VSCode when using Pylance I get the following type check error for runtime argument in _lambda.Function:

Argument of type "(cls: Runtime) -> Runtime" cannot be assigned to parameter "runtime" of type "Runtime" in function "__init__"
  "object" is incompatible with "Runtime"PylancereportGeneralTypeIssues)

Reproduction Steps

Open VSCode and install python extension(which includes pylance)

from aws_cdk import aws_lambda as _lambda

_lambda.Function(
            self,
            'LambdaFunction',
            runtime=_lambda.Runtime.PYTHON_3_8,
            code=_lambda.Code.from_asset('lambda'),
            handler='handler.handler'
        )

What did you expect to happen?

It should not give the type check error since this package is fully typed to help developers.

What actually happened?

It gives type check error.

Environment

  • CDK CLI Version : 1.101.0 (build 149f0fc)
  • Python extension for VSCode version: v2021.5.842923320
  • Language (Version): Python 3.8.6

Other

This is happening because PYTHON_3_8 is a class method not a class property by how it is defined.

    @jsii.python.classproperty # type: ignore[misc]
    @jsii.member(jsii_name="PYTHON_3_8")
    def PYTHON_3_8(cls) -> "Runtime":
        '''The Python 3.8 runtime (python3.8).'''
        return typing.cast("Runtime", jsii.sget(cls, "PYTHON_3_8"))

This is 🐛 Bug Report

@nija-at
Copy link
Contributor

nija-at commented Jun 10, 2021

Transferring this to jsii.

@nija-at nija-at transferred this issue from aws/aws-cdk Jun 10, 2021
@nija-at nija-at removed their assignment Jun 10, 2021
@nija-at nija-at changed the title (lambda): pylance type check error (python): pylance type check error Jun 10, 2021
@peterwoodworth peterwoodworth added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 19, 2021
@gshpychka
Copy link

gshpychka commented Jul 26, 2021

This issue occurs all over with all static "properties" (but in fact methods) like this one.

@NGL321 NGL321 added language/python Related to Python bindings p2 module/jsii Issues affecting the `jsii` module. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2022
@gshpychka
Copy link

This was fixed in #3694

@iliapolo
Copy link
Contributor

iliapolo commented Sep 9, 2024

Duplicate of #3633

@iliapolo iliapolo marked this as a duplicate of #3633 Sep 9, 2024
@iliapolo iliapolo closed this as completed Sep 9, 2024
Copy link
Contributor

github-actions bot commented Sep 9, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/python Related to Python bindings module/jsii Issues affecting the `jsii` module. p2
Projects
None yet
Development

No branches or pull requests

7 participants