Skip to content
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

Imports outside scope affected if import within scope triggered first #42

Open
Mandera opened this issue Jul 15, 2023 · 2 comments
Open

Comments

@Mandera
Copy link
Contributor

Mandera commented Jul 15, 2023

I think that might be the issue, flask is iterating module names internally with this code

    for module in list(sys.modules.values()):
        name = getattr(module, "__file__", None)

        if name is None or name.startswith(_ignore_always):
            continue

Yielding

    if name is None or name.startswith(_ignore_always):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Venvs\Python311\Lib\site-packages\generalimport\fake_module.py", line 19, in error_func
    raise MissingOptionalDependency(f"Optional dependency {name} was used but it isn't installed.")
generalimport.exception.MissingOptionalDependency: Optional dependency 'pandas' was used but it isn't installed.

Didn't look too much into it, but this seems like an issue!
Could allow string methods or something, but that's not the root issue

@Mandera
Copy link
Contributor Author

Mandera commented Jul 15, 2023

  • Have generalfile installed
  • Run flask in dev

@Mandera
Copy link
Contributor Author

Mandera commented Jul 15, 2023

Possible solutions:

  • 34f7bfd tried to remove fake module from sys.modules but failed
  • Perhaps the scope can be applied to the triggering of the errors as well? It should behave nicely if outside the scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant