-
Notifications
You must be signed in to change notification settings - Fork 43
Type Annotations for RestrictedPython #303
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
Draft
loechel
wants to merge
25
commits into
master
Choose a base branch
from
typing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7876a87
Type Annotations for RestrictedPython
loechel 1cd6198
isinstance check with ExtSlice and Tuple as for older Python Versions
loechel e2599ab
liniting
loechel 4915d8e
Remove Python 3.9 as it end of life
loechel 3299a8b
Remove License Cassifier, as they are deprecated
loechel 4d56e39
Add Comment for TryStar Annotation
loechel 935a960
Add Comment for TryStar Annotation
loechel e67da67
Add Comment for TryStar Annotation
loechel 2a3d728
Add Changelog Entry
loechel 3373795
Base for Python 3.14 Updates
loechel f86d895
Update docs for Python 3.14
loechel b4ceb35
add provisional visit_TempalteStr and visit_Interpolation to transfor…
loechel 43941ee
Disable t-strings
loechel f0e2a06
Apply pre-commit code formatting
pre-commit-ci-lite[bot] 26a218c
reactivate Template-Strings
loechel a4e189e
Update Documentation for TemplateStr and Interploation
loechel fd0328a
Apply pre-commit code formatting
pre-commit-ci-lite[bot] aceca07
conditional import
loechel 3533c0f
fix coverage numbers
loechel e750331
readd Python 3.9 support
loechel 44f9842
Merge branch 'master' into typing
dataflake 5b8285c
- updating package files with zope/meta and fixing tests
dataflake ac53335
- fix last test
dataflake 6ecdf5a
Merge branch 'master' into typing
dataflake 0e1408c
- expand change log entry to be more clear.
dataflake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| -- Python 3.14 AST | ||
| -- ASDL's 4 builtin types are: | ||
| -- identifier, int, string, constant | ||
|
|
||
| module Python version "3.14" | ||
| { | ||
| mod = Module(stmt* body, type_ignore* type_ignores) | ||
| | Interactive(stmt* body) | ||
| | Expression(expr body) | ||
| | FunctionType(expr* argtypes, expr returns) | ||
|
|
||
| stmt = FunctionDef(identifier name, | ||
| arguments args, | ||
| stmt* body, | ||
| expr* decorator_list, | ||
| expr? returns, | ||
| string? type_comment, | ||
| type_param* type_params) | ||
| | AsyncFunctionDef(identifier name, | ||
| arguments args, | ||
| stmt* body, | ||
| expr* decorator_list, | ||
| expr? returns, | ||
| string? type_comment, | ||
| type_param* type_params) | ||
|
|
||
| | ClassDef(identifier name, | ||
| expr* bases, | ||
| keyword* keywords, | ||
| stmt* body, | ||
| expr* decorator_list, | ||
| type_param* type_params) | ||
| | Return(expr? value) | ||
|
|
||
| | Delete(expr* targets) | ||
| | Assign(expr* targets, expr value, string? type_comment) | ||
| | TypeAlias(expr name, type_param* type_params, expr value) | ||
| | AugAssign(expr target, operator op, expr value) | ||
| -- 'simple' indicates that we annotate simple name without parens | ||
| | AnnAssign(expr target, expr annotation, expr? value, int simple) | ||
|
|
||
| -- use 'orelse' because else is a keyword in target languages | ||
| | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment) | ||
| | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment) | ||
| | While(expr test, stmt* body, stmt* orelse) | ||
| | If(expr test, stmt* body, stmt* orelse) | ||
| | With(withitem* items, stmt* body, string? type_comment) | ||
| | AsyncWith(withitem* items, stmt* body, string? type_comment) | ||
|
|
||
| | Match(expr subject, match_case* cases) | ||
|
|
||
| | Raise(expr? exc, expr? cause) | ||
| | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) | ||
| | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) | ||
| | Assert(expr test, expr? msg) | ||
|
|
||
| | Import(alias* names) | ||
| | ImportFrom(identifier? module, alias* names, int? level) | ||
|
|
||
| | Global(identifier* names) | ||
| | Nonlocal(identifier* names) | ||
| | Expr(expr value) | ||
| | Pass | ||
| | Break | ||
| | Continue | ||
|
|
||
| -- col_offset is the byte offset in the utf8 string the parser uses | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| -- BoolOp() can use left & right? | ||
| expr = BoolOp(boolop op, expr* values) | ||
| | NamedExpr(expr target, expr value) | ||
| | BinOp(expr left, operator op, expr right) | ||
| | UnaryOp(unaryop op, expr operand) | ||
| | Lambda(arguments args, expr body) | ||
| | IfExp(expr test, expr body, expr orelse) | ||
| | Dict(expr?* keys, expr* values) | ||
| | Set(expr* elts) | ||
| | ListComp(expr elt, comprehension* generators) | ||
| | SetComp(expr elt, comprehension* generators) | ||
| | DictComp(expr key, expr value, comprehension* generators) | ||
| | GeneratorExp(expr elt, comprehension* generators) | ||
| -- the grammar constrains where yield expressions can occur | ||
| | Await(expr value) | ||
| | Yield(expr? value) | ||
| | YieldFrom(expr value) | ||
| -- need sequences for compare to distinguish between | ||
| -- x < 4 < 3 and (x < 4) < 3 | ||
| | Compare(expr left, cmpop* ops, expr* comparators) | ||
| | Call(expr func, expr* args, keyword* keywords) | ||
| | FormattedValue(expr value, int conversion, expr? format_spec) | ||
| | Interpolation(expr value, constant str, int conversion, expr? format_spec) | ||
| | JoinedStr(expr* values) | ||
| | TemplateStr(expr* values) | ||
| | Constant(constant value, string? kind) | ||
|
|
||
| -- the following expression can appear in assignment context | ||
| | Attribute(expr value, identifier attr, expr_context ctx) | ||
| | Subscript(expr value, expr slice, expr_context ctx) | ||
| | Starred(expr value, expr_context ctx) | ||
| | Name(identifier id, expr_context ctx) | ||
| | List(expr* elts, expr_context ctx) | ||
| | Tuple(expr* elts, expr_context ctx) | ||
|
|
||
| -- can appear only in Subscript | ||
| | Slice(expr? lower, expr? upper, expr? step) | ||
|
|
||
| -- col_offset is the byte offset in the utf8 string the parser uses | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| expr_context = Load | ||
| | Store | ||
| | Del | ||
|
|
||
| boolop = And | ||
| | Or | ||
|
|
||
| operator = Add | ||
| | Sub | ||
| | Mult | ||
| | MatMult | ||
| | Div | ||
| | Mod | ||
| | Pow | ||
| | LShift | ||
| | RShift | ||
| | BitOr | ||
| | BitXor | ||
| | BitAnd | ||
| | FloorDiv | ||
|
|
||
| unaryop = Invert | ||
| | Not | ||
| | UAdd | ||
| | USub | ||
|
|
||
| cmpop = Eq | ||
| | NotEq | ||
| | Lt | ||
| | LtE | ||
| | Gt | ||
| | GtE | ||
| | Is | ||
| | IsNot | ||
| | In | ||
| | NotIn | ||
|
|
||
| comprehension = (expr target, expr iter, expr* ifs, int is_async) | ||
|
|
||
| excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body) | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| arguments = (arg* posonlyargs, | ||
| arg* args, | ||
| arg? vararg, | ||
| arg* kwonlyargs, | ||
| expr* kw_defaults, | ||
| arg? kwarg, | ||
| expr* defaults) | ||
|
|
||
| arg = (identifier arg, expr? annotation, string? type_comment) | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| -- keyword arguments supplied to call (NULL identifier for **kwargs) | ||
| keyword = (identifier? arg, expr value) | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| -- import name with optional 'as' alias. | ||
| alias = (identifier name, identifier? asname) | ||
| attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) | ||
|
|
||
| withitem = (expr context_expr, expr? optional_vars) | ||
|
|
||
| match_case = (pattern pattern, expr? guard, stmt* body) | ||
|
|
||
| pattern = MatchValue(expr value) | ||
| | MatchSingleton(constant value) | ||
| | MatchSequence(pattern* patterns) | ||
| | MatchMapping(expr* keys, pattern* patterns, identifier? rest) | ||
| | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns) | ||
|
|
||
| | MatchStar(identifier? name) | ||
| -- The optional "rest" MatchMapping parameter handles capturing extra mapping keys | ||
|
|
||
| | MatchAs(pattern? pattern, identifier? name) | ||
| | MatchOr(pattern* patterns) | ||
|
|
||
| attributes (int lineno, int col_offset, int end_lineno, int end_col_offset) | ||
|
|
||
| type_ignore = TypeIgnore(int lineno, string tag) | ||
|
|
||
| type_param = TypeVar(identifier name, expr? bound, expr? default_value) | ||
| | ParamSpec(identifier name, expr? default_value) | ||
| | TypeVarTuple(identifier name, expr? default_value) | ||
| attributes (int lineno, int col_offset, int end_lineno, int end_col_offset) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Changes from Python 3.13 to Python 3.14 | ||
| --------------------------------------- | ||
|
|
||
| .. literalinclude:: ast/python3_14.ast | ||
| :diff: ast/python3_13.ast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,21 +35,23 @@ def read(*rnames): | |||||||
| long_description_content_type='text/x-rst', | ||||||||
| classifiers=[ | ||||||||
| 'Development Status :: 6 - Mature', | ||||||||
|
||||||||
| 'Development Status :: 6 - Mature', | |
| 'Development Status :: 6 - Mature', | |
| 'License :: OSI Approved :: Zope Public License', |
dataflake marked this conversation as resolved.
Show resolved
Hide resolved
dataflake marked this conversation as resolved.
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.