]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: bump ast_commment version
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 18 Dec 2023 22:33:12 +0000 (23:33 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 18 Dec 2023 23:03:00 +0000 (00:03 +0100)
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.

psycopg/setup.cfg
tools/async_to_sync.py

index ad050fc76beb98373049ea2b18ed588b157aa071..b5010a515ae3ca5df14b49cc7b49633eeb614b27 100644 (file)
@@ -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
index 934df53a4588acd23fb2ce3ba62a7fec4c303027..ece9d9bad2c901afd2ae0c10d74f706b6d310049 100755 (executable)
@@ -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__)