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

Support a config file with example imports #169

Closed
HoverHell opened this issue Dec 6, 2021 · 10 comments
Closed

Support a config file with example imports #169

HoverHell opened this issue Dec 6, 2021 · 10 comments

Comments

@HoverHell
Copy link
Contributor

HoverHell commented Dec 6, 2021

Description

It would be useful to support local conventions (such as import datetime as dt) and names from local modules (from mymodule.mypackage.somewhere import SomeName).

Possible Solution

Doing this requires a config; a most simple config for this would be a py file with example imports.

Example implementation: #170

Additional context

For further consideration: an extra tool for gathering all imports from files, to build such config, to cleanup, tune, and use it.

Related Issue

Can be seen as an alternative to #39

@lyz-code
Copy link
Owner

lyz-code commented Dec 7, 2021

Hi @HoverHell , thank you for taking the time to open an issue. Recently @Jasha10 added support for local configuration, it has been documented here, please take a look and tell me if this will fulfill your use case

@HoverHell
Copy link
Contributor Author

HoverHell commented Dec 8, 2021

I can work around it, with a wrapper like this: https://gist.github.com/HoverHell/b479c566960d91284999f60969bc30f1

However, at the very least that would require config path argument (e.g. #171 )

@lyz-code
Copy link
Owner

lyz-code commented Dec 8, 2021

Adding the --config-file flag makes sense, but sorry, I still don't understand why would you need a wrapper. Can you help me understand what's missing in the current implementation?

If we add the --config-file may I close the other PR you created?

@HoverHell
Copy link
Contributor Author

why would you need a wrapper

It's still missing a global (home-dir) config.

may I close the other PR you created

yes

@Jasha10
Copy link
Contributor

Jasha10 commented Dec 8, 2021

+1 for a --config-file flag :)

@Jasha10
Copy link
Contributor

Jasha10 commented Dec 8, 2021

@HoverHell, by a global (home-dir) config, you mean something like $HOME/.autoimport.toml?

@HoverHell
Copy link
Contributor Author

HoverHell commented Dec 8, 2021 via email

@lyz-code
Copy link
Owner

lyz-code commented Dec 8, 2021

The --config-file flag is available since 0.10.0, thanks @HoverHell ! :)

I see now what you mean, and it makes sense too. The loading of the variables would be in order of preference:

  • pyproject.toml of the repository
  • Global config in ~/.config/autoimport/config.toml
  • Autoimport defaults.

I'm closing #170 as it no longer applies. But if you want to make a PR with the global config, I'll be happy to merge it

@HoverHell
Copy link
Contributor Author

PR with the global config

-> #172

@lyz-code
Copy link
Owner

lyz-code commented Feb 9, 2022

Available since 1.2.0 thanks to @Jasha10 who did a PR based on the work of @HoverHell and the awesome maison library by @dbatten5

@lyz-code lyz-code closed this as completed Feb 9, 2022
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

3 participants