Closed pinkfrog9 closed 9 months ago
Unfortunately, we have no influence on what VS Code / Pylance / Microsoft do. You might have some luck by aliasing the field name explicitly using the alias argument: https://www.attrs.org/en/stable/init.html#private-attributes-and-aliases
yes, using "alias" worked. thanks.
I am curious since instructing with an "alias" field works.
Can we do some control on the "@define" alone, so that the pylance can understand the transformation of private fields (removing the prefixing _)?
Sadly, no. This is something that has to implemented on the Pyright/Pylance side and generally speaking, they only want to implement whatever is officially defined for dataclass transforms. Which is true for alias: https://peps.python.org/pep-0681/#field-specifier-parameters
Given the following code,
The following initialization code will run without error,