• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / RestrictedPython / 27833441635

19 Jun 2026 03:05PM UTC coverage: 98.86% (-0.01%) from 98.874%
27833441635

push

github

web-flow
Type Annotations for RestrictedPython (#317)

* Type Annotations for RestrictedPython

* isinstance check with ExtSlice and Tuple as for older Python Versions

* liniting

* Remove Python 3.9 as it end of life

* Remove License Cassifier, as they are deprecated

* Add Comment for TryStar Annotation

* Add Comment for TryStar Annotation

* Add Comment for TryStar Annotation

* Add Changelog Entry

* Base for Python 3.14 Updates

* Update docs for Python 3.14

* add provisional visit_TempalteStr and visit_Interpolation to transformer to start looking into it

* Disable t-strings

* Apply pre-commit code formatting

* reactivate Template-Strings

* Update Documentation for TemplateStr and Interploation

* Apply pre-commit code formatting

* conditional import

* fix coverage numbers

* readd Python 3.9 support

* - updating package files with zope/meta and fixing tests

* - fix last test

* - expand change log entry to be more clear.

* fix return type

* style update (autopep8)

* add type hints for RestrictingNodeTransformer attributes

* update type hints for RestrictingNodeTransformer methods

* update type hint for `policy` argument

* add type hints for RestrictingNodeTransformer.visit_Interpolation

* update CHANGES.rst

* add types to CompileResult
changing the return type in compile_restricted_function to match the rest of the functions

* fix type hint for used_names

* add None to the return type hints

* add py.typed

* use "normal import"

* add list[ast.AST] to the return type hints

* add config for mypy

* replace `compile(flags=ast.PyCF_ONLY_AST)` to `ast.parse`

* update type hints

* add mypy check in pre-commit

* update type hint

* typeshed is not a package and typeshed include in mypy

* add comment and update type hint after fix #318

* bringing TODO to a single format

---------

Co-authored-by: Alexander Loechel <Alexander.Loechel@lmu.de>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.gi... (continued)

217 of 225 branches covered (96.44%)

219 of 220 new or added lines in 8 files covered. (99.55%)

2601 of 2631 relevant lines covered (98.86%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/RestrictedPython/_types.py
1
import ast
1✔
2
import sys
1✔
3
import typing
1✔
4

5

6
_T = typing.TypeVar('_T')
1✔
7

8

9
def cast_not_none(var: _T | None) -> _T:
1✔
10
    return typing.cast(_T, var)
1✔
11

12

13
# T_pos_ast are subtypes of ast.AST that have a position
14
# (have attributes: lineno, end_lineno, col_offset, and end_col_offset).
15
#
16
# ast.type_param is a new type in python 3.12 that has a position.
17
# TODO: Remove `else` when Support for Python 3.11 is dropped.
18
if sys.version_info >= (3, 12):
1!
19
    T_pos_ast: typing.TypeAlias = (
1✔
20
        ast.stmt | ast.expr | ast.excepthandler | ast.arg | ast.keyword
21
        | ast.alias | ast.pattern | ast.type_param)
22
else:
NEW
23
    T_pos_ast: typing.TypeAlias = (
×
24
        ast.stmt | ast.expr | ast.excepthandler | ast.arg | ast.keyword
25
        | ast.alias | ast.pattern)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc