pyright: add aliasing test (#1063)

This commit is contained in:
Hynek Schlawack 2022-11-30 16:04:57 +01:00 committed by GitHub
parent ee3ecb112f
commit e458448ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,7 @@
# SPDX-License-Identifier: MIT
import attr
import attrs
@attr.define()
@ -43,3 +44,14 @@ d2 = FrozenDefine("a")
d2.a = "new"
reveal_type(d2.a) # noqa
# Field-aliasing works
@attrs.define
class AliasedField:
_a: int = attrs.field(alias="_a")
af = AliasedField(42)
reveal_type(af.__init__) # noqa

View File

@ -75,9 +75,13 @@ def test_pyright_baseline():
severity="information",
message='Type of "d2.a" is "Literal[\'new\']"',
),
PyrightDiagnostic(
severity="information",
message='Type of "af.__init__" is "(_a: int) -> None"',
),
}
assert diagnostics == expected_diagnostics
assert expected_diagnostics == diagnostics
def test_pyright_attrsinstance_compat(tmp_path):