Conversation
Initially we envisioned `pixi.devenv.toml` files dependencies to be included as: ```toml includes = ["../core"] ``` However, in the end we went with a different syntax: ```toml [devenv] upstream = ["../core"] ```
tadeu
approved these changes
Nov 19, 2025
Comment on lines
+109
to
+117
| match data: | ||
| case {"devenv": {"upstream": upstream}} if upstream: | ||
| return [ | ||
| Path(os.path.abspath(dev_env_file.parent / get_relative_path(p))) | ||
| / "pixi.devenv.toml" | ||
| for p in upstream | ||
| ] | ||
| case _: | ||
| return [] |
Contributor
There was a problem hiding this comment.
I really like to avoid those conditionals (case ... if ...:) in match/case constructs =)
>>> def what_is(v):
... match v:
... case [*a]:
... print(f'{a=}')
... case set(b):
... print(f'{b=}')
... case c:
... print(f'{c=}')
...
>>> what_is([1,2,3])
a=[1, 2, 3]
>>> what_is((1,2,3))
a=[1, 2, 3]
>>> what_is({1,2,3})
b={1, 2, 3}
>>> what_is({1:11,2:22,3:33})
c={1: 11, 2: 22, 3: 33}
>>> what_is([])
a=[]
Suggested change
| match data: | |
| case {"devenv": {"upstream": upstream}} if upstream: | |
| return [ | |
| Path(os.path.abspath(dev_env_file.parent / get_relative_path(p))) | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case _: | |
| return [] | |
| match data: | |
| case {"devenv": {"upstream": [*upstream]}}: | |
| return [ | |
| Path(os.path.abspath(dev_env_file.parent / get_relative_path(p))) | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case _: | |
| return [] |
Looks better to me.
And what if that upstream is bound to some other thing like a string?
Contributor
There was a problem hiding this comment.
Maybe it could even be
Suggested change
| match data: | |
| case {"devenv": {"upstream": upstream}} if upstream: | |
| return [ | |
| Path(os.path.abspath(dev_env_file.parent / get_relative_path(p))) | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case _: | |
| return [] | |
| match data: | |
| case {"devenv": {"upstream": [*upstream]}}: | |
| return [ | |
| (dev_env_file.parent / get_relative_path(p)).absolute() | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case {"devenv": {"upstream": invalid_upstream}}: | |
| raise RuntimeError( | |
| f'Invalid upstream declaration: {invalid_upstream!r}\nThe expected value should be a list.' | |
| ) | |
| case _: | |
| return [] |
or even
Maybe it could even be
Suggested change
| match data: | |
| case {"devenv": {"upstream": upstream}} if upstream: | |
| return [ | |
| Path(os.path.abspath(dev_env_file.parent / get_relative_path(p))) | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case _: | |
| return [] | |
| match data: | |
| case {"devenv": {"upstream": [*upstream]}}: | |
| return [ | |
| (dev_env_file.parent / get_relative_path(p)).absolute() | |
| / "pixi.devenv.toml" | |
| for p in upstream | |
| ] | |
| case {"devenv": {"upstream": str(upstream)}}: | |
| return [ | |
| ( | |
| dev_env_file.parent / get_relative_path(upstream) | |
| ).absolute() / "pixi.devenv.toml" | |
| ] | |
| case {"devenv": {"upstream": invalid_upstream}}: | |
| raise RuntimeError( | |
| f'Invalid upstream declaration: {invalid_upstream!r}\nThe expected value should be a list.' | |
| ) | |
| case _: | |
| return [] |
Member
Author
There was a problem hiding this comment.
I think this is a matter of taste, and TBH my version looks better to me, so I will keep my version if you don't mind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initially we envisioned
pixi.devenv.tomlfiles dependencies to be included as:However, in the end we went with a different syntax: