Replace _begin() with start()

This commit is contained in:
Alexander Hess 2026-11-25 17:50:06 +01:00
commit 7ad2e4ee26
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -145,7 +145,7 @@ def format_(session):
If no extra arguments are provided, all source files are formatted. If no extra arguments are provided, all source files are formatted.
Otherwise, they are interpreted as paths the formatters work on recursively. Otherwise, they are interpreted as paths the formatters work on recursively.
""" """
_begin(session) start(session)
# The formatting tools do not require the developed # The formatting tools do not require the developed
# package be installed in the virtual environment. # package be installed in the virtual environment.
@ -173,7 +173,7 @@ def lint(session):
If no extra arguments are provided, all source files are linted. If no extra arguments are provided, all source files are linted.
Otherwise, they are interpreted as paths the linters work on recursively. Otherwise, they are interpreted as paths the linters work on recursively.
""" """
_begin(session) start(session)
# The linting tools do not require the developed # The linting tools do not require the developed
# package be installed in the virtual environment. # package be installed in the virtual environment.
@ -230,7 +230,7 @@ def test(session):
if session.virtualenv.reuse_existing: if session.virtualenv.reuse_existing:
raise RuntimeError('The "test" session must be run without the "-r" option') raise RuntimeError('The "test" session must be run without the "-r" option')
_begin(session) start(session)
# The testing tools require the developed package and its # The testing tools require the developed package and its
# non-develop dependencies be installed in the virtual environment. # non-develop dependencies be installed in the virtual environment.
@ -310,7 +310,7 @@ def test(session):
@nox.session(python=MAIN_PYTHON) @nox.session(python=MAIN_PYTHON)
def safety(session): def safety(session):
"""Check the dependencies for known security vulnerabilities.""" """Check the dependencies for known security vulnerabilities."""
_begin(session) start(session)
# We do not pin the version of `safety` to always check with # We do not pin the version of `safety` to always check with
# the latest version. The risk this breaks the CI is rather low. # the latest version. The risk this breaks the CI is rather low.
@ -341,7 +341,7 @@ def docs(session):
if session.virtualenv.reuse_existing: if session.virtualenv.reuse_existing:
raise RuntimeError('The "docs" session must be run without the "-r" option') raise RuntimeError('The "docs" session must be run without the "-r" option')
_begin(session) start(session)
# The documentation tools require the developed package and its # The documentation tools require the developed package and its
# non-develop dependencies be installed in the virtual environment. # non-develop dependencies be installed in the virtual environment.
@ -583,21 +583,37 @@ def clean_pwd(session):
session.run('rm', '-rf', path) session.run('rm', '-rf', path)
def _begin(session): def start(session: Session) -> None:
"""Show generic info about a session.""" """Show generic info about a session."""
if session.posargs: if session.posargs:
# Part of the hack in pre_merge() to "drop" the extra arguments. session.debug(f'Received extra arguments: {session.posargs}')
# Indicate to stdout that the passed in extra arguments are ignored.
if session.env.get('_drop_posargs') is None:
print('Provided extra argument(s):', *session.posargs) # noqa:WPS421
else:
print('The provided extra arguments are ignored') # noqa:WPS421
session.debug('Some generic information about the environment')
session.run('python', '--version') session.run('python', '--version')
session.run('python', '-c', 'import sys; print(sys.executable)')
session.run('python', '-c', 'import sys; print(sys.path)')
session.run('python', '-c', 'import os; print(os.getcwd())')
session.run('python', '-c', 'import os; print(os.environ["PATH"])')
# Fake GNU's pwd. session.env['BLACK_CACHE_DIR'] = '.cache/black'
session.log('pwd')
print(os.getcwd()) # noqa:WPS421 session.run(
'mkdir',
'-p',
*(
f'.cache/{dir_}'
for dir_ in (
'black',
'coverage',
'mypy',
'nox',
'pytest',
'tmp',
)
),
external=True,
log=False,
)
def install_pinned( def install_pinned(