Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid Python lint warning for @dataclass variable declarations

I am having a try of the dataclasses feature in Python 3.7, but get this warning below word 'hue':

'hue' used before definition
Python (use-before-def)

I suppose it is a linter warrning. I tried several linters that python extension provided, but none of them work.

from dataclasses import dataclass
@dataclass
class Color:
    hue: int
    lightness: float = 2.0
c = Color(2)

Is there a way to have syntax checking etc enabled but avoid receiving this warning?

warning using pep8 warning and err

warning using pylint or mypy warning

like image 572
curtank Avatar asked Dec 21 '18 06:12

curtank


Video Answer


1 Answers

You can set "python.analysis.disabled": ["use-before-def"] to disable the check (docs). The mis-classification of this as an issue has been reported.

like image 143
Brett Cannon Avatar answered Sep 25 '22 03:09

Brett Cannon