Add using ClassAttr instead of ClassVar to rejected ideas (#261)

This commit is contained in:
Ivan Levkivskyi 2017-05-23 03:12:14 +02:00 committed by Brett Cannon
parent 557796b9d9
commit 384ff42460
1 changed files with 9 additions and 4 deletions

View File

@ -484,7 +484,7 @@ Rejected/Postponed Proposals
globals. Second, no matter what we choose, we'd still need
a ``__future__`` import.
- **Use 'def' as a keyword:**
- **Use** ``def`` **as a keyword:**
The proposal would be::
def primes: List[int] = []
@ -514,7 +514,7 @@ Rejected/Postponed Proposals
signature.) Rather than leave the (human) reader guessing, we
forbid this, at least for now.
- **Parenthesized form ``(var: type)`` for annotations:**
- **Parenthesized form** ``(var: type)`` **for annotations:**
It was brought up on python-ideas as a remedy for the above-mentioned
ambiguity, but it was rejected since such syntax would be hairy,
the benefits are slight, and the readability would be poor.
@ -529,7 +529,7 @@ Rejected/Postponed Proposals
it is ambiguous, what should the types of ``y`` and ``z`` be?
Also the second line is difficult to parse.
- **Allow annotations in ``with`` and ``for`` statement:**
- **Allow annotations in** ``with`` **and** ``for`` **statement:**
This was rejected because in ``for`` it would make it hard to spot the actual
iterable, and in ``with`` it would confuse the CPython's LL(1) parser.
@ -577,6 +577,11 @@ Rejected/Postponed Proposals
It could also flag instance variables with mutable defaults,
a well-known hazard.
- **Use** ``ClassAttr`` **instead of** ``ClassVar``:
The main reason why ``ClassVar`` is better is following: many things are
class attributes, e.g. methods, descriptors, etc. But only specific
attributes are conceptually class variables (or maybe constants).
- **Do not evaluate annotations, treat them as strings:**
This would be inconsistent with the behavior of function annotations that
are always evaluated. Although this might be reconsidered in future,
@ -589,7 +594,7 @@ Rejected/Postponed Proposals
This, in turn, would defeat the purpose of the PEP --
collaborating with the third party type checking tools.
- **Implement ``__annotations__`` as a descriptor:**
- **Implement** ``__annotations__`` **as a descriptor:**
This was proposed to prohibit setting ``__annotations__`` to something
non-dictionary or non-None. Guido has rejected this idea as unnecessary;
instead a TypeError will be raised if an attempt is made to update