Skip to content

Commit 073195f

Browse files
committed
fix loggingcase
1 parent 81fff77 commit 073195f

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ repos:
3232
- id: foxylint-imports
3333
name: Import Modules not Names
3434
description: disallows the from_x_import_y import statement
35-
entry: foxylint-imports
35+
entry: foxylint-main imports
3636
language: python
3737
types: [python]
3838
args:
3939
- "--exclude=tests/fixtures/*.py"
4040
- "--exclude=pre-commit-sentinels/**/*.py"
4141
- "--accept=/from mylogging/"
42+
- id: foxylint-loggingcase
43+
name: Enforce lowercase logging
44+
description: do not capitalize sentences in log messages like you would in ordinary English
45+
entry: foxylint-main loggingcase
46+
language: python
47+
types: [python]
48+
args:
49+
- "--exclude=tests/fixtures/*.py"
4250
- id: yaml-not-yml
4351
name: YAML files must end with .yaml
4452
description: disallows the .yml suffix, allows only .yaml

.pre-commit-hooks.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
- id: foxylint-imports
22
name: Import Modules not Names
33
description: disallows the from_x_import_y import statement
4-
entry: foxylint-imports
4+
entry: foxylint-main imports
5+
language: python
6+
types: [python]
7+
- id: foxylint-loggingcase
8+
name: Enforce lowercase logging
9+
description: do not capitalize sentences in log messages like you would in ordinary English
10+
entry: foxylint-main loggingcase
511
language: python
612
types: [python]
713
- id: yaml-not-yml

foxylint/main.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import glob
44
import foxylint.imports
5+
import foxylint.loggingcase
56

67

78
def red(text):
@@ -12,11 +13,7 @@ def bold(text):
1213
return click.secho(text, fg='white', bold=True)
1314

1415

15-
@click.command()
16-
@click.argument('files', nargs=-1, type=click.Path())
17-
@click.option('--exclude', '-e', multiple=True)
18-
@click.option('--accept', multiple=True)
19-
def main(files, exclude, accept):
16+
def _find_files(files, exclude):
2017
excluded = []
2118
for pattern in exclude:
2219
excluded.extend(glob.glob(pattern, recursive=True))
@@ -29,8 +26,10 @@ def main(files, exclude, accept):
2926
if os.path.abspath(file) not in excluded:
3027
files.append(file)
3128

32-
accept = [pattern.strip('/') for pattern in accept]
33-
findings = foxylint.imports.analyze(files, acceptable_patterns=accept)
29+
return files
30+
31+
32+
def _show_findings(findings):
3433
bad_files = 0
3534
for file, analysis in findings.items():
3635
if analysis['ok']:
@@ -45,3 +44,31 @@ def main(files, exclude, accept):
4544
quit(1)
4645
else:
4746
quit(0)
47+
48+
49+
@click.group()
50+
@click.pass_context
51+
def main(context):
52+
pass
53+
54+
55+
@main.command()
56+
@click.pass_context
57+
@click.argument('files', nargs=-1, type=click.Path())
58+
@click.option('--exclude', '-e', multiple=True)
59+
@click.option('--accept', multiple=True)
60+
def imports(context, files, exclude, accept):
61+
files = _find_files(files, exclude)
62+
accept = [pattern.strip('/') for pattern in accept]
63+
findings = foxylint.imports.analyze(files, acceptable_patterns=accept)
64+
_show_findings(findings)
65+
66+
67+
@main.command()
68+
@click.pass_context
69+
@click.argument('files', nargs=-1, type=click.Path())
70+
@click.option('--exclude', '-e', multiple=True)
71+
def loggingcase(context, files, exclude):
72+
files = _find_files(files, exclude=exclude)
73+
findings = foxylint.loggingcase.analyze(files)
74+
_show_findings(findings)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "foxylint"
3-
version = "1.2.0"
3+
version = "1.3.0"
44
description = ""
55
authors = ["Yoav Kleinberger <[email protected]>"]
66
license = "MIT"
@@ -23,5 +23,5 @@ build-backend = "poetry.core.masonry.api"
2323

2424

2525
[tool.poetry.scripts]
26-
foxylint-imports = 'foxylint.main:main'
26+
foxylint-main = 'foxylint.main:main'
2727
foxylint-noyml = 'foxylint.noyml:main'

0 commit comments

Comments
 (0)