Class-qualified annotation expressions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
The wonderfully useful specification of type annotation expressions describes what kinds of expressions are valid type annotations.
I believe the spec does not include a case which type checkers support, although as we will see this comes down to semantics :)
class A:
class B:
pass
x: A.B = A.B()
The A.B annotation seems to fall under the name rule:
| name
(where name must refer to a valid in-scope class,
type alias, or TypeVar)
The spec helpfully continues:
Any leaf denoted as name may also be a qualified name (i.e., module '.' name or package '.' module '.' name, with any level of nesting).
The concept of a "qualified name" occurs only in this section, and the parenthetical explanation serves as it's most precise definition, as far as I can tell.
Should we extend the definition of "qualified name" to also include class members? Or maybe I should read the class as a "module" or a "package" and the existing definition suffices?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the type and annotation expressions specification, especially the definition of name and qualified name, and compare it with the A.B example in the issue. Review how existing type checkers interpret class-qualified annotations; done means the specification clearly states whether class members are included and how the example is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100