johnthagen / sealed-typing-pep Goto Github PK
View Code? Open in Web Editor NEWA PEP to add a `@sealed` typing decorator to Python
License: MIT License
A PEP to add a `@sealed` typing decorator to Python
License: MIT License
Other languages that use sealed
require that all subtypes be defined in the same file. This likely makes it tractable for type checkers to know all subtypes of a sealed
class.
Direct subclasses of sealed classes and interfaces must be declared in the same package.
Traits and classes can be marked sealed which means all subtypes must be declared in the same file. This assures that all subtypes are known.
A class is sealed by applying the sealed modifier to its declaration. Then, after any extends and implements clauses, the permits clause specifies the classes that are permitted to extend the sealed class. For example, the following declaration of Shape specifies three permitted subclasses:
package com.example.geometry;
public abstract sealed class Shape
permits Circle, Rectangle, Square { ... }
We should update the rejected ideas section for Union types to include the _T
base class method that has been proposed before and highlight the challenges that it has
sealed
enum
|
)PEP 622 (which was later superseded) has a complete description for @sealed
.
PEP 591 should be a good example to look at, as @final
is similar in scope to @sealed
.
typing.assert_never()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.