Run linting and formatting checks.
(session: nox.Session)
| 359 | |
| 360 | @nox.session(name="pep8", python="3.14") |
| 361 | def test_pep8(session: nox.Session) -> None: |
| 362 | """Run linting and formatting checks.""" |
| 363 | |
| 364 | for pattern in ["*.so", "*.pyd", "*.dylib"]: |
| 365 | for filepath in Path("lib/sqlalchemy").rglob(pattern): |
| 366 | filepath.unlink() |
| 367 | |
| 368 | session.install("-e", ".") |
| 369 | |
| 370 | session.install(*nox.project.dependency_groups(pyproject, "lint")) |
| 371 | |
| 372 | failed = [] |
| 373 | |
| 374 | for cmd in [ |
| 375 | "flake8p ./lib/ ./test/ ./examples/ noxfile.py " |
| 376 | "setup.py doc/build/conf.py", |
| 377 | # run "unused argument" lints on asyncio, as we have a lot of |
| 378 | # proxy methods here |
| 379 | "flake8p --ignore='' --select='U100,U101' " |
| 380 | "./lib/sqlalchemy/ext/asyncio " |
| 381 | "./lib/sqlalchemy/orm/scoping.py", |
| 382 | "black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py", |
| 383 | "slotscheck -m sqlalchemy", |
| 384 | "python ./tools/format_docs_code.py --check", |
| 385 | "python ./tools/generate_tuple_map_overloads.py --check", |
| 386 | "python ./tools/generate_proxy_methods.py --check", |
| 387 | "python ./tools/sync_test_files.py --check", |
| 388 | "python ./tools/generate_sql_functions.py --check", |
| 389 | "python ./tools/normalize_file_headers.py --check", |
| 390 | "python ./tools/cython_imports.py --check", |
| 391 | "python ./tools/walk_packages.py", |
| 392 | ]: |
| 393 | try: |
| 394 | session.run(*cmd.split()) |
| 395 | except CommandFailed as err: |
| 396 | failed.append((cmd, err)) |
| 397 | |
| 398 | if failed: |
| 399 | session.error(f"failed with {len(failed)} errors") |