-
Notifications
You must be signed in to change notification settings - Fork 387
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
Pump Version python to 3.12, 3.13. Allow pip install for python 3.12, 3.13 #210
base: main
Are you sure you want to change the base?
Changes from all commits
d75e6ad
2842b03
2a79b0a
bca27e1
fea131d
a8db822
024023f
bb4ef32
e8c56ca
4a85faf
45345d7
74f83b7
7705e3a
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ build-backend = "hatchling.build" | |
name = "latexify-py" | ||
description = "Generates LaTeX math description from Python functions." | ||
readme = "README.md" | ||
requires-python = ">=3.7, <3.12" | ||
requires-python = ">=3.9, <3.14" | ||
license = {text = "Apache Software License 2.0"} | ||
authors = [ | ||
{name = "Yusuke Oda", email = "[email protected]"} | ||
|
@@ -24,11 +24,11 @@ classifiers = [ | |
"Framework :: IPython", | ||
"Framework :: Jupyter", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
"Topic :: Scientific/Engineering :: Mathematics", | ||
"Topic :: Software Development :: Code Generators", | ||
"Topic :: Text Processing :: Markup :: LaTeX", | ||
|
@@ -43,17 +43,17 @@ dynamic = [ | |
[project.optional-dependencies] | ||
dev = [ | ||
"build>=0.8", | ||
"black>=22.10", | ||
"flake8>=5.0", | ||
"black>=24.3", | ||
"flake8>=6.0", | ||
"isort>=5.10", | ||
"mypy>=0.991", | ||
"mypy>=1.9", | ||
"notebook>=6.5.1", | ||
"pyproject-flake8>=5.0", | ||
"pyproject-flake8>=6.0", | ||
"pytest>=7.1", | ||
"twine>=4.0", | ||
] | ||
mypy = [ | ||
"mypy>=0.991", | ||
"mypy>=1.9", | ||
"pytest>=7.1", | ||
] | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||
from __future__ import annotations | ||||||
|
||||||
import ast | ||||||
import sys | ||||||
from typing import Any | ||||||
|
||||||
import pytest | ||||||
|
@@ -34,29 +35,6 @@ def test_make_attribute() -> None: | |||||
) | ||||||
|
||||||
|
||||||
@test_utils.require_at_most(7) | ||||||
maycuatroi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
(None, ast.NameConstant(value=None)), | ||||||
(False, ast.NameConstant(value=False)), | ||||||
(True, ast.NameConstant(value=True)), | ||||||
(..., ast.Ellipsis()), | ||||||
(123, ast.Num(n=123)), | ||||||
(4.5, ast.Num(n=4.5)), | ||||||
(6 + 7j, ast.Num(n=6 + 7j)), | ||||||
("foo", ast.Str(s="foo")), | ||||||
(b"bar", ast.Bytes(s=b"bar")), | ||||||
], | ||||||
) | ||||||
def test_make_constant_legacy(value: Any, expected: ast.Constant) -> None: | ||||||
test_utils.assert_ast_equal( | ||||||
observed=ast_utils.make_constant(value), | ||||||
expected=expected, | ||||||
) | ||||||
|
||||||
|
||||||
@test_utils.require_at_least(8) | ||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
|
@@ -83,25 +61,23 @@ def test_make_constant_invalid() -> None: | |||||
ast_utils.make_constant(object()) | ||||||
|
||||||
|
||||||
@test_utils.require_at_most(7) | ||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
(ast.Bytes(s=b"foo"), True), | ||||||
(ast.Constant("bar"), True), | ||||||
(ast.Ellipsis(), True), | ||||||
(ast.NameConstant(value=None), True), | ||||||
(ast.Num(n=123), True), | ||||||
(ast.Str(s="baz"), True), | ||||||
(ast.Expr(value=ast.Num(456)), False), | ||||||
(ast.Constant(value=b"foo"), True), | ||||||
(ast.Constant(value="bar"), True), | ||||||
(ast.Constant(value=...), True), | ||||||
(ast.Constant(value=None), True), | ||||||
(ast.Constant(value=123), True), | ||||||
(ast.Constant(value="baz"), True), | ||||||
(ast.Expr(value=ast.Constant(value=456)), False), | ||||||
(ast.Global(names=["qux"]), False), | ||||||
], | ||||||
) | ||||||
def test_is_constant_legacy(value: ast.AST, expected: bool) -> None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks there exists some test cases from that only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The decorator (@test_utils.require_at_most(7)) was previously used to indicate that the test case would run on Python versions >= 3.7. So, even when we were on Python 3.9, the test case was still executed. Now that we've upgraded to at least Python 3.9, the test case should still run as intended. I believe it’s best to keep the test case as it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
latexify_py/src/latexify/test_utils.py Lines 51 to 52 in 678cd0e
|
||||||
assert ast_utils.is_constant(value) is expected | ||||||
|
||||||
|
||||||
@test_utils.require_at_least(8) | ||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
|
@@ -114,25 +90,23 @@ def test_is_constant(value: ast.AST, expected: bool) -> None: | |||||
assert ast_utils.is_constant(value) is expected | ||||||
|
||||||
|
||||||
@test_utils.require_at_most(7) | ||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
(ast.Bytes(s=b"foo"), False), | ||||||
(ast.Constant("bar"), True), | ||||||
(ast.Ellipsis(), False), | ||||||
(ast.NameConstant(value=None), False), | ||||||
(ast.Num(n=123), False), | ||||||
(ast.Str(s="baz"), True), | ||||||
(ast.Expr(value=ast.Num(456)), False), | ||||||
(ast.Constant(value=b"foo"), False), | ||||||
(ast.Constant(value="bar"), True), | ||||||
(ast.Constant(value=...), False), | ||||||
(ast.Constant(value=None), False), | ||||||
(ast.Constant(value=123), False), | ||||||
(ast.Constant(value="baz"), True), | ||||||
(ast.Expr(value=ast.Constant(value=456)), False), | ||||||
(ast.Global(names=["qux"]), False), | ||||||
], | ||||||
) | ||||||
def test_is_str_legacy(value: ast.AST, expected: bool) -> None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test case as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with decorator @test_utils.require_at_most(7) |
||||||
assert ast_utils.is_str(value) is expected | ||||||
|
||||||
|
||||||
@test_utils.require_at_least(8) | ||||||
@pytest.mark.parametrize( | ||||||
"value,expected", | ||||||
[ | ||||||
|
@@ -194,6 +168,7 @@ def test_extract_int_invalid() -> None: | |||||
ast.Call( | ||||||
func=ast.Name(id="hypot", ctx=ast.Load()), | ||||||
args=[], | ||||||
keywords=[], | ||||||
), | ||||||
"hypot", | ||||||
), | ||||||
|
@@ -205,17 +180,58 @@ def test_extract_int_invalid() -> None: | |||||
ctx=ast.Load(), | ||||||
), | ||||||
args=[], | ||||||
keywords=[], | ||||||
), | ||||||
"hypot", | ||||||
), | ||||||
( | ||||||
ast.Call( | ||||||
func=ast.Call(func=ast.Name(id="foo", ctx=ast.Load()), args=[]), | ||||||
func=ast.Call( | ||||||
func=ast.Name(id="foo", ctx=ast.Load()), args=[], keywords=[] | ||||||
), | ||||||
args=[], | ||||||
keywords=[], | ||||||
), | ||||||
None, | ||||||
), | ||||||
], | ||||||
) | ||||||
def test_extract_function_name_or_none(value: ast.Call, expected: str | None) -> None: | ||||||
assert ast_utils.extract_function_name_or_none(value) == expected | ||||||
|
||||||
|
||||||
def test_create_function_def() -> None: | ||||||
expected_args = ast.arguments( | ||||||
posonlyargs=[], | ||||||
args=[ast.arg(arg="x")], | ||||||
vararg=None, | ||||||
kwonlyargs=[], | ||||||
kw_defaults=[], | ||||||
kwarg=None, | ||||||
defaults=[], | ||||||
) | ||||||
|
||||||
kwargs = { | ||||||
"name": "test_func", | ||||||
"args": expected_args, | ||||||
"body": [ast.Return(value=ast.Name(id="x", ctx=ast.Load()))], | ||||||
"decorator_list": [], | ||||||
"returns": None, | ||||||
"type_comment": None, | ||||||
"lineno": 1, | ||||||
"col_offset": 0, | ||||||
"end_lineno": 2, | ||||||
"end_col_offset": 0, | ||||||
} | ||||||
if sys.version_info.minor >= 12: | ||||||
kwargs["type_params"] = [] | ||||||
|
||||||
func_def = ast_utils.create_function_def(**kwargs) | ||||||
assert isinstance(func_def, ast.FunctionDef) | ||||||
assert func_def.name == "test_func" | ||||||
|
||||||
assert func_def.args.posonlyargs == expected_args.posonlyargs | ||||||
assert func_def.args.args == expected_args.args | ||||||
assert func_def.args.kwonlyargs == expected_args.kwonlyargs | ||||||
assert func_def.args.kw_defaults == expected_args.kw_defaults | ||||||
assert func_def.args.defaults == expected_args.defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add type hints.