Skip to content

Commit

Permalink
- support Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Oct 8, 2024
1 parent 95f323c commit 69c2ca8
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.13.0-alpha - 3.13.0", "py313"]
- ["3.13", "py313"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["3.9", "py39-datetime"]
Expand All @@ -48,6 +48,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config[0] }}
allow-prereleases: true
- name: Pip cache
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ testenv-additional = [
" coverage combine",
" coverage html",
" coverage report -m --fail-under=100",
"depends = py37,py38,py39,py39-datetime,py310,py311,py312,coverage",
"depends = py37,py38,py39,py39-datetime,py310,py311,py312,py313,coverage",
]
coverage-basepython = "python3.8"
coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}"
Expand Down
3 changes: 1 addition & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Changes
7.4 (unreleased)
----------------

- Allow to use the package with Python 3.13 -- Caution: No security
audit has been done so far.
- Allow to use the package with Python 3.13.


7.3 (2024-09-30)
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = {'.rst': 'restructuredtext'}

# The encoding of source files.
# source_encoding = 'utf-8-sig'
Expand Down Expand Up @@ -113,6 +113,7 @@
'python310': ('https://docs.python.org/3.10', None),
'python311': ('https://docs.python.org/3.11', None),
'python312': ('https://docs.python.org/3.12', None),
'python313': ('https://docs.python.org/3.13', None),
}

# Options for sphinx.ext.todo:
Expand Down
194 changes: 194 additions & 0 deletions docs/contributing/ast/python3_13.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
-- Python 3.13 AST
-- ASDL's 4 builtin types are:
-- identifier, int, string, constant

module Python version "3.13"
{
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)
| JoinedStr(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)
}
5 changes: 5 additions & 0 deletions docs/contributing/changes_from312to313.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changes from Python 3.12 to Python 3.13
---------------------------------------

.. literalinclude:: ast/python3_13.ast
:diff: ast/python3_12.ast
1 change: 1 addition & 0 deletions docs/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ A (modified style) Copy of all Abstract Grammar Definitions for the Python versi
changes_from39to310
changes_from310to311
changes_from311to312
changes_from312to313

.. _understand:

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def read(*rnames):
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Security',
],
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ envlist =
usedevelop = true
package = wheel
wheel_build_env = .pkg
pip_pre = py313: true
deps =
datetime: DateTime
-cconstraints.txt
pytest-cov
Sphinx
setenv =
COVERAGE_FILE=.coverage.{envname}
py312: VIRTUALENV_PIP=23.1.2
py312: PIP_REQUIRE_VIRTUALENV=0
commands =
python -V
pytest --cov=src --cov=tests --cov-report= {posargs}
Expand All @@ -54,7 +51,8 @@ commands =
coverage combine
coverage html
coverage report -m --fail-under=100
depends = py37,py38,py39,py39-datetime,py310,py311,py312,coverage
depends = py37,py38,py39,py39-datetime,py310,py311,py312,py313,coverage

[testenv:release-check]
description = ensure that the distribution is ready to release
basepython = python3
Expand Down

0 comments on commit 69c2ca8

Please sign in to comment.