-
-
Notifications
You must be signed in to change notification settings - Fork 127
Add @disjoint_base (PEP 800)
#634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8b51be6
7b00a6a
f75df29
7b6b3a3
808a0d2
80cbeb8
05acc47
4c3ad58
d38ef90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,7 @@ | |
| 'reveal_type', | ||
| 'runtime', | ||
| 'runtime_checkable', | ||
| 'solid_base', | ||
| 'Text', | ||
| 'TypeAlias', | ||
| 'TypeAliasType', | ||
|
|
@@ -315,6 +316,32 @@ class Other(Leaf): # Error reported by type checker | |
| return f | ||
|
|
||
|
|
||
| if hasattr(typing, "solid_base"): | ||
JelleZijlstra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| solid_base = typing.solid_base | ||
| else: | ||
| def solid_base(cls): | ||
| """This decorator marks a class a solid base. | ||
| Child classes of a solid base cannot inherit from other solid bases that are | ||
JelleZijlstra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| not parent classes of the solid base. | ||
|
|
||
| For example: | ||
|
|
||
| @solid_base | ||
| class Solid1: pass | ||
|
|
||
| @solid_base | ||
| class Solid2: pass | ||
|
|
||
| class Solid3(Solid1, Solid2): pass # Type checker error | ||
|
|
||
| Type checkers can use solid bases to detect unreachable code | ||
JelleZijlstra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| and determine when two types can overlap. | ||
|
|
||
| See PEP 800.""" | ||
| cls.__solid_base__ = True | ||
|
||
| return cls | ||
|
|
||
|
|
||
| def IntVar(name): | ||
| return typing.TypeVar(name) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.