Skip to content
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

Default value for filename in nox.project.load_toml #843

Open
paduszyk opened this issue Aug 30, 2024 · 4 comments
Open

Default value for filename in nox.project.load_toml #843

paduszyk opened this issue Aug 30, 2024 · 4 comments

Comments

@paduszyk
Copy link

How would this feature be useful?

I think most people will use the nox.project.load_toml function (added in #811) with their pyproject.toml. In fact, the name of the function itself suggests loading from a TOML.

Describe the solution you'd like

I would update the function's signature:

def load_toml(filename: os.PathLike[str] | str) -> dict[str, Any]:

with:

def load_toml(filename: os.PathLike[str] | str = "pyproject.toml") -> dict[str, Any]: 

or set the default to None and evaluate the file location from pwd:

def load_toml(filename: os.PathLike[str] | str | None = None) -> dict[str, Any]: 
    if filename is None:
        filename = Path.cwd() / "pyproject.toml"

    # ...

Describe alternatives you've considered

Alternatively, the path to the pyproject.toml can be set via nox.options.

Anything else?

No response

@CAM-Gerlach
Copy link

CAM-Gerlach commented Sep 5, 2024

Not a Nox maintainer or anything, but FYI, you can just do Path("pyproject.toml") rather than the unnecessary Path.cwd() / "pyproject.toml", since filename doesn't require absolute paths (as the example indeed shows).

@henryiii
Copy link
Collaborator

henryiii commented Sep 9, 2024

The function was actually added to make loading PEP 723 files easier, since it's a pretty trivial wrapper over tomllib/tomli otherwise. But defaulting to pyprojec.toml doesn't seem unreasonable.

@paduszyk
Copy link
Author

Not a Nox maintainer or anything, but FYI, you can just do Path("pyproject.toml") rather than the unnecessary Path.cwd() / "pyproject.toml", since filename doesn't require absolute paths (as the example indeed shows).

@CAM-Gerlach Yeah. Maybe I've been too much into PEP 20, line 2: Explicit is better than implicit. 😄

@CAM-Gerlach
Copy link

Well, as I am a PEP editor, I can say that despite the widespread misconception to the contrary, PEP 20 (the Zen of Python) was never intended to be taken seriously as a set of rules for the language, as opposed to one core dev's tongue in cheek ideas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants