-
Notifications
You must be signed in to change notification settings - Fork 3
Implement usethis tool import-linter
#98
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
Comments
As a default, we could create an exhaustive, layer contract with sibling-relationships allowed between all modules, put into the same layer. We would ask the user to manually strengthen the contract. At a later point, perhaps we can create a contract guesser which tries to do something more powerful. |
As far as config goes, something like this, as a draft: # https://import-linter.readthedocs.io/en/stable/usage.html#configuration-file-location
def get_managed_files(self) -> list[Path]:
return [Path(".importlinter")]
def get_managed_setup_cfg_keys(self) -> list[list[str]]:
return [["importlinter"]]
def get_managed_pyproject_keys(self) -> list[list[str]]:
return [["tool", "importlinter"]] And then for the algorithm, we would go through In our box_print message when adding the tool, we need to note that the command is |
We've got a function which provides a layered architecture for a given package, ready for use in A few edge cases to handle:
Actually, all these edge cases are basically in the same category of "don't have any configuration to put down". |
Another edge case: import-linter assumes properly configured packages, i.e. not missing This is related to #128. |
Ah, easy, via experiment it turns out that empty config works ok: [tool.importlinter]
root_packages = [ "example" ]
[[tool.importlinter.contracts]]
name = "Modular Design"
type = "layers"
layers = []
containers = [ "example" ]
exhaustive = true |
Actually, that doesn't necessarily solve the case where there is no package at all though, only an empty package. I think warning about the need for |
If we can't find any packages, I reckon we just exit with an error, and messages explaining that a package is required. We could add a hint suggesting Alternatively, we could use the project name and add an empty contract. I think that's better but we should display a warning. We'd also need to regularize the name so that it's a valid Python package name. |
Closed by #528. |
Motivation
This is another super powerful (and underrated) linter which is configured for the project but would be worth supporting in
usethis
.Summary of desired enhancement
We want a
usethis tool import-linter
interface.The tricky part is deciding how to add contracts. Possibly there is some clever logic we can use to guess a good contract. Alternatively, we could provide a template and ask the user to populate it. We can point the user to the docs.
The text was updated successfully, but these errors were encountered: