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

Notify sessions with multiple interpreters #883

Open
leodevian opened this issue Nov 2, 2024 · 0 comments
Open

Notify sessions with multiple interpreters #883

leodevian opened this issue Nov 2, 2024 · 0 comments

Comments

@leodevian
Copy link

leodevian commented Nov 2, 2024

How would this feature be useful?

This would enable notifying sessions with multiple interpreters. Today, running nox against the following noxfile.py will only run coverage and tests under Python 3.10. I feel like it should run tests under all interpreters.

import nox

nox.options.sessions = ["coverage"]


@nox.session
def coverage(session: nox.Session) -> None:
    """Erase coverage."""
    session.install("coverage")
    session.run("coverage", "erase")
    session.notify("tests")


@nox.session(python=("3.10", "3.11", "3.12", "3.13"))
def tests(session: nox.Session) -> None:
    """Run tests and collect coverage."""
    session.install(".")
    session.install("pytest", "coverage")
    session.run("coverage", "run", "-m", "pytest")

Describe the solution you'd like

I would update nox.manifest.Manifest.notify with the following code to catch all matching sessions.

nox/nox/manifest.py

Lines 400 to 407 in 6f3a459

# Locate the session in the list of all sessions, and place it at
# the end of the queue.
for s in self._all_sessions:
if s == session or s.name == session or session in s.signatures: # noqa: PLR1714
if posargs is not None:
s.posargs = list(posargs)
self._queue.append(s)
return True

# Locate the sessions in the list of all sessions.
sessions: list[SessionRunner] = []

for s in self._all_sessions:
    if s == session or s.name == session or session in s.signatures:  # noqa: PLR1714
        if posargs is not None:
            s.posargs = list(posargs)
        sessions.append(s)

# Place sessions at the end of the queue.
if sessions:
    self._queue.extend(sessions)
    return True

Describe alternatives you've considered

Today, I can chain those sessions using nox.options.sessions, but that forces me to declare them as default sessions.

Anything else?

If this gets approved, could I do the PR myself? It would be my first contribution ever.

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

No branches or pull requests

1 participant