Skip to content

Commit 819a751

Browse files
committed
Replaced local ruff/yamllint w/ almighty pre-commit hooks everywhere to cover all filetypes
1 parent 2cefa4c commit 819a751

15 files changed

Lines changed: 91 additions & 28 deletions

File tree

computer-languages/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1616
def dev(session) : session.run('pip', 'install', '-e', '.')
1717

1818
@session
19-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
19+
def lint(session): # staged project files
20+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
21+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2022
@session
21-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
23+
def lint_all(session): # all project files
24+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
25+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2226

2327
@session
2428
def update(session, *args) : session.run('py', paths.utils.update, *args)

data-languages/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1616
def dev(session) : session.run('pip', 'install', '-e', '.')
1717

1818
@session
19-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
19+
def lint(session): # staged project files
20+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
21+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2022
@session
21-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
23+
def lint_all(session): # all project files
24+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
25+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2226

2327
@session
2428
def update(session, *args) : session.run('py', paths.utils.update, *args)

find-project-root/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ def test_py26(session):
2626
clean(session, '--py2')
2727

2828
@session
29-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
29+
def lint(session): # staged project files
30+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
31+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
3032
@session
31-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
33+
def lint_all(session): # all project files
34+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
35+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
3236

3337
@session
3438
def bump_patch(session, no_push=True):

get-min-py/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ def dev(session) : session.run('pip', 'install', '-e', '.') ; session.run(pkg.di
1717
def debug(session) : session.run('py', '-m', pkg.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
1818

1919
@session
20-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
20+
def lint(session): # staged project files
21+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
22+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2123
@session
22-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
24+
def lint_all(session): # all project files
25+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
26+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2327

2428
@session
2529
def bump_patch(session, no_push=True):

is-unicode-supported/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ def dev(session) : session.run('pip', 'install', '-e', '.') ; session.run(pkg.di
1717
def debug(session) : session.run('py', '-m', pkg.name, '--debug', *session.posargs, env={ 'PYTHONPATH': 'src' })
1818

1919
@session
20-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
20+
def lint(session): # staged project files
21+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
22+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2123
@session
22-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
24+
def lint_all(session): # all project files
25+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
26+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2327

2428
@session
2529
def bump_patch(session, no_push=True):

latin-locales/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1515
def dev(session) : session.run('pip', 'install', '-e', '.')
1616

1717
@session
18-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
18+
def lint(session): # staged project files
19+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
20+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
1921
@session
20-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
22+
def lint_all(session): # all project files
23+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
24+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2125

2226
@session
2327
def bump_patch(session, no_push=True):

markup-languages/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1616
def dev(session) : session.run('pip', 'install', '-e', '.')
1717

1818
@session
19-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
19+
def lint(session): # staged project files
20+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
21+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2022
@session
21-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
23+
def lint_all(session): # all project files
24+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
25+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2226

2327
@session
2428
def update(session, *args) : session.run('py', paths.utils.update, *args)

non-latin-locales/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1515
def dev(session) : session.run('pip', 'install', '-e', '.')
1616

1717
@session
18-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
18+
def lint(session): # staged project files
19+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
20+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
1921
@session
20-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
22+
def lint_all(session): # all project files
23+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
24+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2125

2226
@session
2327
def bump_patch(session, no_push=True):

noxfile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import nox
2+
3+
def session(func) : return nox.session(venv_backend='none', name=func.__name__.replace('_', '-'))(func)
4+
5+
@session
6+
def lint(session): # staged monorepo files
7+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
8+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
9+
10+
@session
11+
def lint_all(session): # all monorepo files
12+
session.run('pre-commit', 'run', '--all-files', *session.posargs)

programming-languages/noxfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ def session(func) : return nox.session(venv_backend='none', name=func.__name__.r
1616
def dev(session) : session.run('pip', 'install', '-e', '.')
1717

1818
@session
19-
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
19+
def lint(session): # staged project files
20+
files = session.run('git', 'diff', '--cached', '--name-only', '--relative', silent=True, log=False).splitlines()
21+
if files : session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2022
@session
21-
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
23+
def lint_all(session): # all project files
24+
files = session.run('git', 'ls-files', '.', silent=True, log=False).splitlines()
25+
session.run('pre-commit', 'run', '--files', *files, *session.posargs)
2226

2327
@session
2428
def update(session, *args) : session.run('py', paths.utils.update, *args)

0 commit comments

Comments
 (0)