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

Ban import for file pattern #424

Closed
Niccolum opened this issue Jan 31, 2023 · 2 comments
Closed

Ban import for file pattern #424

Niccolum opened this issue Jan 31, 2023 · 2 comments

Comments

@Niccolum
Copy link

Niccolum commented Jan 31, 2023

Description

Thanks for your library!

For me and my command it will be nice to have possibility to import some local files in a certain way.

For example, I have

controllers/
- __init__.py
- controller1.py
- controller2.py

In __init__.py i write

from .controller1 import ControllerOne
from .controller2 import ControllerTwo

And inside controller1.py i want to use ControllerTwo.

So, if i write in controller1.py

from controllers import ControllerTwo

it will be a circular import, but if I write something like

from controllers.controller2 import ControllerTwo 

It will work.

So, I want to restrict in some files import some modules "in short way" to avoid circular import. But outside controllers - any files can import any controller in short way

Is it possible with your plugin to do somethibg like it? Could you consider such functionality for yourself?

Thanks for any reply!

@adamchainz
Copy link
Owner

I like this idea for neatness - we do the same kind of thing within Django. But I think the request is too complicated for this plugin. For fine-grained import rules, you can use Import Linter.

@Niccolum
Copy link
Author

Thanks for your response, @adamchainz . I saw this tool, but it's so hard to use it without seddonym/import-linter#56
Oh, i will waiting. Thanks!

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

No branches or pull requests

2 participants