pyright: add aliasing test (#1063)
This commit is contained in:
parent
ee3ecb112f
commit
e458448ee4
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue