Small improvements to Python API#411
Conversation
Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
…n API Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
ac8dc4c to
a3fc735
Compare
For now I don't consider bindings/core API a part of stability guarantee; too few users to matter. |
It would be better to use an enum in Python API, otherwise we have to check if both |
| class SourcesMode(Enum): | ||
| OWN = auto() | ||
| """Only the project's own sources""" | ||
| OWN_WITH_DEPS = auto() | ||
| """The project's own sources together with its dependencies' sources""" | ||
| DEPS = auto() | ||
| """Only the dependencies' sources""" |
There was a problem hiding this comment.
IMO a better design would be to have:
- a flag/arg
no_ownto exclude self sources, which are included by default - a flag/arg
includewith variants:deps(show deps excluding std)deps-std(show deps including std)std(show only std)none(don't show deps)
Any combination of no_own and include is valid.
There was a problem hiding this comment.
(with no dependencies shown by default)
| let root = e.root_path(); | ||
| root.canonicalize_utf8() | ||
| .map_err(|err| Box::new(FsIoError::Canonicalize(root.to_owned(), err))) |
There was a problem hiding this comment.
| let root = e.root_path(); | |
| root.canonicalize_utf8() | |
| .map_err(|err| Box::new(FsIoError::Canonicalize(root.to_owned(), err))) | |
| wrapfs::canonicalize(e.root_path()) |
There was a problem hiding this comment.
Implementation is fine, but I really don't like the design and defaults. I'd like to make invalid states unrepresentable, my previous comment details what that would look like.
Bindings can be more or less freely altered (very few users), so I would like bindings to have my proposed design, while CLI will wait until 0.2.0 to match. Alternatively, we could release this now, but I would still like to make the change on the next breaking release, and breaking the functionality soon after releasing it is not appealing.
This PR contains small Python API improvements that I need for integrating Sysand into Syside ReqIF functionality, namely:
print-root, but not in Python)These changes required a bit of changes on the Sysand core / CLI, namely the introduction of "source modes":
own, which represents the "I only want to list theincludedfiles" and was achievable through CLI assysand sources --no-deps(still possible)own_with_deps, which is what the default issysand sourcesdeps, which is new and returns only the dependencies withoutincludedfilesWhile the CLI only got a new flag
--only-depsand thus there is no breaking change on the CLI side, the Python API lost theinclude_depsargument and gainedno_depsandonly_depsinstead to better align with the CLI. Not sure if we should consider this a breaking change, or should I try to keep what was already in the Python API?For context, this is how I would need to get only the deps with the current API:
While after this PR I will be able to do:
P.S.: The commits are pretty atomic and contain nice commit messages. If not a lot of changes after review are required, I'd like NOT to squash the commits on merge.