From: Daniele Varrazzo Date: Mon, 18 Dec 2023 22:33:12 +0000 (+0100) Subject: chore: bump ast_commment version X-Git-Tag: 3.2.0~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96e8db185d72d881da7626d5ec77e03ca91c9f05;p=thirdparty%2Fpsycopg.git chore: bump ast_commment version Drop workarounds for a couple of bugs which have been fixed upstream. Force re-generation of the docker image when the ast_comment module changes. --- diff --git a/psycopg/setup.cfg b/psycopg/setup.cfg index ad050fc76..b5010a515 100644 --- a/psycopg/setup.cfg +++ b/psycopg/setup.cfg @@ -73,8 +73,7 @@ test = pytest-cov >= 3.0 pytest-randomly >= 3.5 dev = - # Version pinned to work around https://github.com/t3rn0/ast-comments/issues/21 - ast-comments==1.1.0 + ast-comments >= 1.1.2 black >= 23.1.0 codespell >= 2.2 dnspython >= 2.1 diff --git a/tools/async_to_sync.py b/tools/async_to_sync.py index 934df53a4..ece9d9bad 100755 --- a/tools/async_to_sync.py +++ b/tools/async_to_sync.py @@ -2,6 +2,11 @@ """Convert async code in the project to sync code. Note: the version of Python used to run this script affects the output. + +Hint: in order to explore the AST of a module you can run: + + python -m ast path/to/module.py + """ from __future__ import annotations @@ -14,22 +19,10 @@ from copy import deepcopy from typing import Any, Literal from pathlib import Path from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter +from importlib.metadata import version import ast_comments as ast -# ast_comment versions 1.1.0, 1.1.1 have an import: -# -# from typing import Dict, List, Tuple, Union -# -# which shadows some of the types defined in ast. -# -# Reported in https://github.com/t3rn0/ast-comments/issues/22 -import ast as ast_orig - -ast.Dict = ast_orig.Dict -ast.List = ast_orig.List -ast.Tuple = ast_orig.Tuple - # The version of Python officially used for the conversion. # Output may differ in other versions. # Should be consistent with the Python version used in lint.yml @@ -79,7 +72,12 @@ def main() -> int: current_ver, ) logger.warning( - " You might get spurious changes that will be rejected by the CI linter." + "You might get spurious changes that will be rejected by the CI linter." + ) + logger.warning( + "(use %s {--docker | --podman} to run it with Python %s in a container)", + sys.argv[0], + PYVER, ) outputs = [] @@ -136,7 +134,7 @@ def run_in_container(engine: Literal["docker", "podman"]) -> int: """ Build an image and run the script in a container. """ - tag = f"async-to-sync:{PYVER}" + tag = f"async-to-sync:{version('ast_comments')}-{PYVER}" # Check if the image we want is present. cmdline = [engine, "inspect", tag, "-f", "{{ .Id }}"] @@ -182,10 +180,6 @@ def tree_to_str(tree: ast.AST, filepath: Path) -> str: return rv -# Hint: in order to explore the AST of a module you can run: -# python -m ast path/tp/module.py - - class AsyncToSync(ast.NodeTransformer): def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> ast.AST: new_node = ast.FunctionDef(**node.__dict__)