-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
NameError Importing local packages in Alembic Operations 1.7.2 #920
Comments
well here's the problem. we use exec() around your registered function. in 1.6.5, this is the text we exec'ed: def replace_view(self, target, replaces=None, replace_with=None):
None
return op_cls.replace(self, target, replaces=replaces, replace_with=replace_with) in 1.7.x, it's this: def replace_view(self, target: fun_stuff.alembic_utils.ReplaceableObject, replaces: Optional[str]=None, replace_with: Optional[str]=None) -> None:
None
return op_cls.replace(self, target, replaces=replaces, replace_with=replace_with) hence the problem. I'd have to trace out how we made it add the annotations like that, which I believe we need for internal ops, for now it seems best that external ops would not render annotations or we'd have some option for imports. @CaselIT any ideas, but ill keep looking in a bit |
A simple one could be to just render all annotations as strings |
ooh we can do that too. i was just going to have it not render the annotations but yes |
we need to render the annotations for our op.pyi thing right? |
Mike Bayer has proposed a fix for this issue in the master branch: render 3rd party module annotations as forward references https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/3082 |
I think they could work the same, but I think having a flag there to enable/disable it would not be too hard |
this should work well |
Wow you all are fast. Thank you! |
@zzzeek - this still happens when registering an operation that has a parameter with a type annotation of something like |
please open a new issue with an example, thanks! |
Describe the bug
Importing local packages creates NameError in version 1.7.2 was not the case in 1.6.5
Expected behavior
Ability to use locally installed packages in alembic revisions
To Reproduce
Local Package "fun_stuff" installed via -e
The details on this file come from replaceable objects cookbook
fun_stuff/alembic_utils.py
24627210e3e6_swap_old_with_new.py
The error below occurs when running
alembic history
Error
Versions.
Additional context
This is not a problem in alembic 1.6.5. I love the project!
The text was updated successfully, but these errors were encountered: