Replies: 4 comments 3 replies
-
Great ideas @gwdekker! When developing |
Beta Was this translation helpful? Give feedback.
-
About automation/an sdk, I'll give it some thought! Meanwhile, here's an approach that can be used already today: |
Beta Was this translation helpful? Give feedback.
-
Thanks! Write a function (using poly internals) to find all components in a project that are not needed by its basesfrom pathlib import Path
from polylith_cli.polylith import info, deps
from polylith_cli.polylith.commands.deps import get_bases
root_path = Path("xxx")
assert root_path.is_dir()
def poly_components_not_needed_by_bases_per_project(root: Path) -> dict:
root = root_path
ns: str = "xxx"
projects_data = info.get_projects_data(root, ns)
components_not_needed_by_bases = dict()
for project in projects_data:
if project["type"] != "project":
continue
bases = get_bases(root, ns, project)
imports = flatten_imports(deps.get_brick_imports(root, ns, bases, components={}))
components_not_needed_by_bases[project["name"]] = set(project["components"]) - imports
return components_not_needed_by_bases
def flatten_imports(imports: dict) -> set:
return set().union(*imports["bases"].values()) | set().union(*imports["components"].values())
print(poly_components_not_needed_by_bases_per_project(root_path)) Add an ignorelist optionin Something like this: [tool.polylith.projects.extra_bricks_needed]
# Linting checks per project if the bricks listed are (transitive) dependencies of their bases. If you for some reason
# need to add a component that is not a dependency of the bases, you can add it here as an exception, with your project name as key and your component names as a list
project_name = ["component1", "component2"]
run this through either a unit test or a pre-commit hookTo be decided. Curious what you think about this approach! |
Beta Was this translation helpful? Give feedback.
-
Ongoing work, extending |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I would like to do the following: for a certain project, I want to do a strict dependency check. What i mean by that: i want to verify that all components in the projects'
pyproject.toml
are strictly needed by the bases that are imported in that same project. As I often see that after a refactoring, certain bricks are not needed anymore but AFAIK these are not being picked up by any of thepoly
commands so far.I could imagine this being already a flag on
poly check
, something likepoly check --strict-components
. Is that something you would consider?Second, related question: when trying to figure out how to build this myself i found
poly deps --brick
which I could already make use of. However, to make that easy I would like to be able to do the following:Any pointers on how to achieve that?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions