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

Use-before-def reported for class fields without default values #395

Description

Environment data
VS Code version: 1.29.0
Extension version (available under the Extensions sidebar): 2018.10.1
OS and version: OSX
Python version (& distribution if applicable, e.g. Anaconda): python 3.7
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv

Actual behavior
Python 3.7 dataclass properties are incorrectly reported as "used before definition". The same syntax with default values added is not reported.

screen shot 2018-11-14 at 07 54 00

Expected behavior
The properties are not reported.

Steps to reproduce:
See screenshot above.

BTW: is it possible (as a workaround to above issue) to suppress warnings for a given block/line?

Activity

  1. jakebailey commented on Nov 14, 2018

    @jakebailey
    Member

    The analyzer only offers basic detection of use-before-def and unresolved imports, and doesn't have the ability to disable checks per line (#264). What you can do in the meantime is disable the diagnostic in your settings, like:

    "python.analysis.disabled": [
        "use-before-def"
    ]

    And use something like pylint which I don't believe will misreport this (with the downside that it can only be run on save, while the language server can do these checks instantly).

  2. changed the title [-]Incorrect reporting of dataclass properties[/-] [+]Use-before-def reported for class fields without default values[/+] on Nov 14, 2018
  3. lukaselmer commented on Nov 15, 2018

    @lukaselmer

    I have the same issue.

    Jake Bailey (@jakebailey) there is a typo in anaysis - it should be

    "python.analysis.disabled": [
        "use-before-def"
    ]
  4. jakebailey commented on Nov 15, 2018

    @jakebailey
    Member

    Agh, yeah, sorry.

  5. koliyo commented on Dec 14, 2018

    @koliyo

    I hope these issues become a priority. VS code should really encourage the usage of the typing syntax!

  6. brettcannon commented on Jan 3, 2019

    @brettcannon
    Member
  7. removed this from the Feb 2019.2 milestone on Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions