]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Improve write_pyi usage 1525/head
authorAaron Griffin <aaron@growtherapy.com>
Wed, 28 Aug 2024 21:36:30 +0000 (16:36 -0500)
committerAaron Griffin <aaron@growtherapy.com>
Wed, 28 Aug 2024 21:36:30 +0000 (16:36 -0500)
Due to some problems when running write_pyi, this includes the following
changes:

1. move the sys.path.append up before alembic is imported - this is
   using global imports otherwise
2. use tox to run write_pyi in order to avoid globally installed
   dependencies

tools/write_pyi.py
tox.ini

index 363d727ec98ba5d83bf3fb69a4da67fd0b4de22f..b2ad23001f38832364f33a4c82c4bf552edd80ee 100644 (file)
@@ -11,12 +11,12 @@ from tempfile import NamedTemporaryFile
 import textwrap
 import typing
 
+sys.path.append(str(Path(__file__).parent.parent))
+
 from alembic.autogenerate.api import AutogenContext
 from alembic.ddl.impl import DefaultImpl
 from alembic.runtime.migration import MigrationInfo
 
-sys.path.append(str(Path(__file__).parent.parent))
-
 if True:  # avoid flake/zimports messing with the order
     from alembic.operations.base import BatchOperations
     from alembic.operations.base import Operations
diff --git a/tox.ini b/tox.ini
index f1bfcac35235edca0c8981fc4d6d22a69af3f287..77439be377f29cf433760d89db6fea514f617bb1 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -101,3 +101,12 @@ deps=
 commands =
      flake8 ./alembic/ ./tests/ setup.py docs/build/conf.py {posargs}
      black --check setup.py tests alembic
+
+[testenv:write_pyi]
+basepython = python3
+deps=
+    sqlalchemy>=2
+    mako
+    zimports
+    black==24.1.1
+commands = python tools/write_pyi.py