microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 767 forks source link

Type Checking Warnings show up with Type Checking disabled #5695

Closed Rawalanche closed 6 months ago

Rawalanche commented 6 months ago

Pylance reportInvalidTypeForm warnings appear in the VSCode problems list despite type checking being completely disabled: image

"python.analysis.diagnosticSeverityOverrides": {"reportInvalidTypeForm": "none"} does work to solve the problem but I don't understand how this can have any effect when it's preceded by "python.analysis.typeCheckingMode": "off"

Code Snippet

class LK_QUICK_THEME_properties(bpy.types.PropertyGroup):
    """Properties for the addon"""
    skip_update: BoolProperty(name="Skip Update", default=False)

Repro Steps

  1. Declare one or more properties using colon characters followed by call expression
  2. Have Pylance type checking completely disabled

Expected behavior

Type checking warnings do not appear in the Problems list because type checking is disabled

Actual behavior

Type checking warnings appear in the Problems list despite type checking being disabled

erictraut commented 6 months ago

This behavior is intended. Type annotations are used for type analysis regardless of whether you're interested in static type checking. Therefore, it's important for type annotations, if present, to use correct expression forms. Your code is using an expression form that is illegal for type annotations. This problem impacts all type evaluations and will likely affect your experience with code completions, etc. For that reason, it's important to warn you about the problem regardless of whether other static type checking errors are reported.

You can manually disable all reportInvalidTypeForm diagnostics if you would like, but I recommend against it. It's better if you correct the problems in your code and use type annotations in accordance with the Python typing spec.

For a full list of default diagnostic severities, refer to this documentation. Note that several diagnostic rules are set to "warning" severity even if the type checking mode is set to "off".

Rawalanche commented 6 months ago

This behavior is intended. Type annotations are used for type analysis regardless of whether you're interested in static type checking. Therefore, it's important for type annotations, if present, to use correct expression forms. Your code is using an expression form that is illegal for type annotations. This problem impacts all type evaluations and will likely affect your experience with code completions, etc. For that reason, it's important to warn you about the problem regardless of whether other static type checking errors are reported.

You can manually disable all reportInvalidTypeForm diagnostics if you would like, but I recommend against it. It's better if you correct the problems in your code and use type annotations in accordance with the Python typing spec.

For a full list of default diagnostic severities, refer to this documentation. Note that several diagnostic rules are set to "warning" severity even if the type checking mode is set to "off".

I wish I could do something better about it, but I can't unfortunately. This syntax is mandatory in Blender's python API, and Blender is the largest, most popular open source 3D modeling/editing software. I don't know who's at wrong here, but I don't have any better choice than to turn these warnings off and bury my head in the sand :/

debonte commented 6 months ago

@Rawalanche, also see the discussion in https://github.com/microsoft/pylance-release/issues/5457.