Skip to content

Commit be3fbdf

Browse files
committed
Upgrade add-trailing-comma to 0.4.0
1 parent 7aeb4fe commit be3fbdf

File tree

9 files changed

+216
-199
lines changed

9 files changed

+216
-199
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
- id: reorder-python-imports
2323
language_version: python2.7
2424
- repo: https://github.com/asottile/add-trailing-comma
25-
sha: v0.3.0
25+
sha: v0.4.0
2626
hooks:
2727
- id: add-trailing-comma

CONTRIBUTING.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,6 @@ variable `slowtests=false`.
4646

4747
With the environment activated simply run `pre-commit install`.
4848

49-
## Style
50-
51-
This repository follows pep8 (and enforces it with flake8). There are a few
52-
nitpicky things I also like that I'll outline below.
53-
54-
### Multi-line method invocation
55-
56-
Multiple line method invocation should look as follows
57-
58-
```python
59-
function_call(
60-
argument,
61-
argument,
62-
argument,
63-
)
64-
```
65-
66-
Some notable features:
67-
- The initial parenthesis is at the end of the line
68-
- Parameters are indented one indentation level further than the function name
69-
- The last parameter contains a trailing comma (This helps make `git blame`
70-
more accurate and reduces merge conflicts when adding / removing parameters).
71-
7249
## Documentation
7350

7451
Documentation is hosted at http://pre-commit.com

pre_commit/languages/ruby.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ def get_env_patch(venv, language_version): # pragma: windows no cover
2424
('GEM_HOME', os.path.join(venv, 'gems')),
2525
('RBENV_ROOT', venv),
2626
('BUNDLE_IGNORE_CONFIG', '1'),
27-
('PATH', (
28-
os.path.join(venv, 'gems', 'bin'), os.pathsep,
29-
os.path.join(venv, 'shims'), os.pathsep,
30-
os.path.join(venv, 'bin'), os.pathsep, Var('PATH'),
31-
)),
27+
(
28+
'PATH', (
29+
os.path.join(venv, 'gems', 'bin'), os.pathsep,
30+
os.path.join(venv, 'shims'), os.pathsep,
31+
os.path.join(venv, 'bin'), os.pathsep, Var('PATH'),
32+
),
33+
),
3234
)
3335
if language_version != 'default':
3436
patches += (('RBENV_VERSION', language_version),)

testing/fixtures.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ def modify_config(path='.', commit=True):
6969
def config_with_local_hooks():
7070
return OrderedDict((
7171
('repo', 'local'),
72-
('hooks', [OrderedDict((
73-
('id', 'do_not_commit'),
74-
('name', 'Block if "DO NOT COMMIT" is found'),
75-
('entry', 'DO NOT COMMIT'),
76-
('language', 'pcre'),
77-
('files', '^(.*)$'),
78-
))]),
72+
(
73+
'hooks', [OrderedDict((
74+
('id', 'do_not_commit'),
75+
('name', 'Block if "DO NOT COMMIT" is found'),
76+
('entry', 'DO NOT COMMIT'),
77+
('language', 'pcre'),
78+
('files', '^(.*)$'),
79+
))],
80+
),
7981
))
8082

8183

tests/clientlib_test.py

Lines changed: 81 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -56,94 +56,100 @@ def test_validate_config_main(args, expected_output):
5656
assert validate_config_main(args) == expected_output
5757

5858

59-
@pytest.mark.parametrize(('config_obj', 'expected'), (
60-
([], False),
61-
(
62-
[{
63-
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
64-
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
65-
'hooks': [{'id': 'pyflakes', 'files': '\\.py$'}],
66-
}],
67-
True,
68-
),
69-
(
70-
[{
71-
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
72-
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
73-
'hooks': [
74-
{
75-
'id': 'pyflakes',
76-
'files': '\\.py$',
77-
'args': ['foo', 'bar', 'baz'],
78-
},
79-
],
80-
}],
81-
True,
82-
),
83-
(
84-
[{
85-
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
86-
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
87-
'hooks': [
88-
{
89-
'id': 'pyflakes',
90-
'files': '\\.py$',
91-
# Exclude pattern must be a string
92-
'exclude': 0,
93-
'args': ['foo', 'bar', 'baz'],
94-
},
95-
],
96-
}],
97-
False,
59+
@pytest.mark.parametrize(
60+
('config_obj', 'expected'), (
61+
([], False),
62+
(
63+
[{
64+
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
65+
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
66+
'hooks': [{'id': 'pyflakes', 'files': '\\.py$'}],
67+
}],
68+
True,
69+
),
70+
(
71+
[{
72+
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
73+
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
74+
'hooks': [
75+
{
76+
'id': 'pyflakes',
77+
'files': '\\.py$',
78+
'args': ['foo', 'bar', 'baz'],
79+
},
80+
],
81+
}],
82+
True,
83+
),
84+
(
85+
[{
86+
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
87+
'sha': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
88+
'hooks': [
89+
{
90+
'id': 'pyflakes',
91+
'files': '\\.py$',
92+
# Exclude pattern must be a string
93+
'exclude': 0,
94+
'args': ['foo', 'bar', 'baz'],
95+
},
96+
],
97+
}],
98+
False,
99+
),
98100
),
99-
))
101+
)
100102
def test_config_valid(config_obj, expected):
101103
ret = is_valid_according_to_schema(config_obj, CONFIG_SCHEMA)
102104
assert ret is expected
103105

104106

105-
@pytest.mark.parametrize('config_obj', (
106-
[{
107-
'repo': 'local',
108-
'sha': 'foo',
109-
'hooks': [{
110-
'id': 'do_not_commit',
111-
'name': 'Block if "DO NOT COMMIT" is found',
112-
'entry': 'DO NOT COMMIT',
113-
'language': 'pcre',
114-
'files': '^(.*)$',
107+
@pytest.mark.parametrize(
108+
'config_obj', (
109+
[{
110+
'repo': 'local',
111+
'sha': 'foo',
112+
'hooks': [{
113+
'id': 'do_not_commit',
114+
'name': 'Block if "DO NOT COMMIT" is found',
115+
'entry': 'DO NOT COMMIT',
116+
'language': 'pcre',
117+
'files': '^(.*)$',
118+
}],
115119
}],
116-
}],
117-
))
120+
),
121+
)
118122
def test_config_with_local_hooks_definition_fails(config_obj):
119123
with pytest.raises(schema.ValidationError):
120124
schema.validate(config_obj, CONFIG_SCHEMA)
121125

122126

123-
@pytest.mark.parametrize('config_obj', (
124-
[{
125-
'repo': 'local',
126-
'hooks': [{
127-
'id': 'arg-per-line',
128-
'name': 'Args per line hook',
129-
'entry': 'bin/hook.sh',
130-
'language': 'script',
131-
'files': '',
132-
'args': ['hello', 'world'],
127+
@pytest.mark.parametrize(
128+
'config_obj', (
129+
[{
130+
'repo': 'local',
131+
'hooks': [{
132+
'id': 'arg-per-line',
133+
'name': 'Args per line hook',
134+
'entry': 'bin/hook.sh',
135+
'language': 'script',
136+
'files': '',
137+
'args': ['hello', 'world'],
138+
}],
133139
}],
134-
}],
135-
[{
136-
'repo': 'local',
137-
'hooks': [{
138-
'id': 'arg-per-line',
139-
'name': 'Args per line hook',
140-
'entry': 'bin/hook.sh',
141-
'language': 'script',
142-
'files': '',
143-
'args': ['hello', 'world'],
144-
}]
145-
}],
146-
))
140+
[{
141+
'repo': 'local',
142+
'hooks': [{
143+
'id': 'arg-per-line',
144+
'name': 'Args per line hook',
145+
'entry': 'bin/hook.sh',
146+
'language': 'script',
147+
'files': '',
148+
'args': ['hello', 'world'],
149+
}]
150+
}],
151+
),
152+
)
147153
def test_config_with_local_hooks_definition_passes(config_obj):
148154
schema.validate(config_obj, CONFIG_SCHEMA)
149155

tests/color_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
from pre_commit.color import use_color
1212

1313

14-
@pytest.mark.parametrize(('in_text', 'in_color', 'in_use_color', 'expected'), (
15-
('foo', GREEN, True, '{}foo\033[0m'.format(GREEN)),
16-
('foo', GREEN, False, 'foo'),
17-
))
14+
@pytest.mark.parametrize(
15+
('in_text', 'in_color', 'in_use_color', 'expected'), (
16+
('foo', GREEN, True, '{}foo\033[0m'.format(GREEN)),
17+
('foo', GREEN, False, 'foo'),
18+
),
19+
)
1820
def test_format_color(in_text, in_color, in_use_color, expected):
1921
ret = format_color(in_text, in_color, in_use_color)
2022
assert ret == expected

0 commit comments

Comments
 (0)