Hi, I have an issue which boils down to the same point in alembic code, but I'm not using any development-only script, but [post_write_hooks] feature.
Relevant part of alembic.ini:
[post_write_hooks]
# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black, isort
black.type = console_scripts
black.entrypoint = black
black.options = REVISION_SCRIPT_FILENAME
isort.type = console_scripts
isort.entrypoint = isort
isort.options = REVISION_SCRIPT_FILENAME
16:18 $ poetry run alembic revision --autogenerate -m "Add foobar"
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Generating /home/foobar/myproject/api/migrations/versions/2021_09_27_6c36df7b6df9_add_foobar.py ... done
Running post write hook "black" ...
FAILED
Traceback (most recent call last):
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/bin/alembic", line 8, in <module>
sys.exit(main())
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/config.py", line 588, in main
CommandLine(prog=prog).main(argv=argv)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/config.py", line 582, in main
self.run_cmd(cfg, options)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/config.py", line 559, in run_cmd
fn(
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/command.py", line 234, in revision
scripts = [script for script in revision_context.generate_scripts()]
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/command.py", line 234, in <listcomp>
scripts = [script for script in revision_context.generate_scripts()]
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/autogenerate/api.py", line 600, in generate_scripts
yield self._to_script(generated_revision)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/autogenerate/api.py", line 505, in _to_script
return self.script_directory.generate_revision(
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/script/base.py", line 736, in generate_revision
write_hooks._run_hooks(path, post_write_hooks)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/script/write_hooks.py", line 84, in _run_hooks
util.status(
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/util/messaging.py", line 56, in status
ret = fn(*arg, **kw)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/script/write_hooks.py", line 58, in _invoke
return hook(revision, options)
File "/home/foobar/.cache/pypoetry/virtualenvs/someenv-py3.8/lib/python3.8/site-packages/alembic/script/write_hooks.py", line 145, in console_scripts
"import %s; %s.%s()" % (impl.module, impl.module, impl.attr),
AttributeError: 'EntryPoint' object has no attribute 'module'
The origin of the issue is of course the same, alembic/script/write_hooks.py seems to be working with python 3.9+ as discovered above:
This happens, because the code assumes (write_hooks.py:141), that the returned object EntryPoint has a module or attr property (which it has on 3.9, but not on 3.8).
While write_pyi.py is an script for development use only, I guess that all post-write hooks deal with the same issue as well?
Originally posted by @antoni-szych-rtbhouse in #915 (comment)
Hi, I have an issue which boils down to the same point in alembic code, but I'm not using any development-only script, but
[post_write_hooks]feature.Relevant part of alembic.ini:
The origin of the issue is of course the same,
alembic/script/write_hooks.pyseems to be working with python 3.9+ as discovered above:While
write_pyi.pyis an script for development use only, I guess that all post-write hooks deal with the same issue as well?Originally posted by @antoni-szych-rtbhouse in #915 (comment)