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

Get style file from python package #202

Closed
isac322 opened this issue Sep 5, 2020 · 3 comments · Fixed by #407
Closed

Get style file from python package #202

isac322 opened this issue Sep 5, 2020 · 3 comments · Fixed by #407
Labels
enhancement New feature or request plugin-python Plugin for Python files released Feature/fix is released

Comments

@isac322
Copy link
Contributor

isac322 commented Sep 5, 2020

Expected Behavior

tool.nitpick.style of pyproject.toml can load style which in some python package.

Current Behavior

tool.nitpick.style accept absolute file path or URL

Possible Solution

Structure of some_python_package

src/some_python_package
├── __init__.py
├── plugin.py
├── plugin.pyi
├── py.typed
└── styles
    ├── black.toml
    ├── flake8.toml
    ├── mypy.toml
    └── nitpick-style.toml

String way

pyproject.toml

[tool.nitpick]
style = "pypackage://some_python_package.styles.nitpick-style.toml"

Dict way

pyproject.toml

[tool.nitpick]
style = { module: "some_python_package.styles", resource: "nitpick-style.toml" }

Context

My company has dozens of python projects. We have company wide flake8 rules and I want to share tool configurations across those projects with the flake8 rules. So I created a flake8 plugin and include nitpick-style.toml. But because nitpick only accept pure file path, I can not reference the nitpick-style.toml.

@isac322 isac322 added the enhancement New feature or request label Sep 5, 2020
@andreoliwa
Copy link
Owner

Hi @isac322, sorry for not replying earlier.

But because nitpick only accept pure file path

Did you try relative file paths for the style files?

We have company wide flake8 rules and I want to share tool configurations across those projects with the flake8 rules

Why can't you use a remote URL with your shared style?
Check the docs:

You can set style with any local file or URL. E.g.: you can use the raw URL of a GitHub Gist.

Something like this on pyproject.toml:

[tool.nitpick]
style = ["https://raw.githubusercontent.com/your-company/<your-shared-project-with-configs/your-branch/nitpick-style.toml"]

Maybe the docs are not clear to explain this situation, I can improve them.

@isac322
Copy link
Contributor Author

isac322 commented Oct 5, 2020

Hi @andreoliwa ,
Thanks for replying.
Currently we use remote style URL. But still I want to distribute both custom flake8 rules and nitpick style at the same time. (So I include nitpick style within package as resource). Because we want to use versioning for consistency.
But currently I have to specify version on two places. One on requirements.txt for custom plugin, one on pyproject.toml for nitpick. So it would be good if nitpick can read style file from a python package. To remove duplicated versioning and to avoid human error!
Thanks

@andreoliwa andreoliwa added the plugin-python Plugin for Python files label Feb 13, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 0.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Feature/fix is released label Oct 27, 2021
@andreoliwa andreoliwa moved this to Done in Nitpick Roadmap Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin-python Plugin for Python files released Feature/fix is released
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants