-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature: Extend ruff configuration from external file #12352
Comments
|
Thanks @yeoffrey for opening this issue and the kind words. The first step for adding preset support is to create a design proposal and consensus behind it.
|
If the configuration needs to be available at install time and not fetching at runtime, then I think the best option would be to create a preset as a development dependency that is installed with all of the other python packages. Inside of the ruff configuration file, you could point to a dependency that exports a configuration. I see this being a way to solve the question of caching, avoiding HTTP downloads during file traversal, ensuring reproducible builds. It also just leverages python's existing package system, so it doesn't feel unintuitive to handle it this way. pip install my-ruff-config # ruff.toml
[preset]
pkg = "my-ruff-config" The only issue I see though, is how to export a toml file out of a python package:
I think presets should be able to be extended, but based on the documentation I don't think To make it work there should be an order of priority:
These are just my basic thoughts right now, I might have others later. |
I'm not sure that i understand what you mean by that. I like using Python packages. The main question is how to find the Python package. More specifically. How do we know where the venv is (if any) |
For projects like eslint and typescript it's easy: whatever environment they're run from so they can just import. pyright is a non-python tool that needs to be aware of installed python packages, maybe you could take some inspiration from how it's doing it? Eric T. is generally a good reference for such standards too. I see what looks like static typing efforts in Ruff (that red-knot thing?). Surely logic to statically find installed packages can be shared. |
TD;LR
Enable the ability to import ruff.toml configurations from external sources such as URLs or git repositories.
✅ I am willing to contribute to make this feature.
Use Case
In our own projects, we maintain multiple repositories. When we need to update our linting rules, we currently have to modify the ruff.toml file in each project individually. This process is time-consuming and prone to inconsistencies. It would be beneficial to centralize these configurations, allowing us to update rules in a single location and propagate them across all projects.
For our Javascript projects, we have a shared eslint configuration from a repository that is imported via a project dependency. When we make an update to the configuration, the dependency will update. It saves us a lot of time, and I think Ruff should have a similar solution available for this case.
Proposed Solution
Introduce support for remote imports in ruff.toml. This feature would allow users to specify an external URL or git repository from which the ruff.toml configuration can be fetched and extended. This could be implemented either as a Python dependency or directly in the ruff.toml file.
Example Configuration
Conclusion
This feature would streamline the process of sharing and updating linter configurations across multiple projects, enhancing maintainability and consistency. Centralizing configuration management would save time and reduce errors. Thank you for your continued efforts and a brilliant tool 🚀
The text was updated successfully, but these errors were encountered: