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