nebius/SWE-bench-extra huggingface dataset:
Repository: asottile/add-trailing-comma

Issue:
escaped newlines are throwing off indent detection
This should be a noop:

```python
x = y.\
    foo(
        bar,
    )
```

However, this is the current behaviour:

```diff
 x = y.\
     foo(
         bar,
-    )
+)
```

Might need help from https://github.com/asottile/tokenize-rt/issues/1

Comments:

Patch:
diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 7a571a7..882cb9d 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -7,6 +7,7 @@ import collections
 import io
 import sys
 
+from tokenize_rt import ESCAPED_NL
 from tokenize_rt import src_to_tokens
 from tokenize_rt import Token
 from tokenize_rt import tokens_to_src
@@ -20,8 +21,8 @@ Literal = collections.namedtuple('Literal', ('node', 'backtrack'))
 Literal.__new__.__defaults__ = (False,)
 Fix = collections.namedtuple('Fix', ('braces', 'multi_arg', 'initial_indent'))
 
-NEWLINES = frozenset(('NEWLINE', 'NL'))
-NON_CODING_TOKENS = frozenset(('COMMENT', 'NL', UNIMPORTANT_WS))
+NEWLINES = frozenset((ESCAPED_NL, 'NEWLINE', 'NL'))
+NON_CODING_TOKENS = frozenset(('COMMENT', ESCAPED_NL, 'NL', UNIMPORTANT_WS))
 INDENT_TOKENS = frozenset(('INDENT', UNIMPORTANT_WS))
 START_BRACES = frozenset(('(', '{', '['))
 END_BRACES = frozenset((')', '}', ']'))
diff --git a/setup.py b/setup.py
index 39c86ff..828d6a9 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ setup(
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy',
     ],
-    install_requires=['tokenize-rt'],
+    install_requires=['tokenize-rt>=2'],
     py_modules=['add_trailing_comma'],
     entry_points={
         'console_scripts': ['add-trailing-comma = add_trailing_comma:main'],


Test patch:
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index 9f67fb3..d41af5c 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -501,6 +501,11 @@ def test_fix_unhugs_py3_only(src, expected):
         '        1, 2, 3, 4,\n'
         '    ],\n'
         ']',
+        # Regression test for #11
+        'foo.\\\n'
+        '    bar(\n'
+        '        5,\n'
+        '    )',
     ),
 )
 def test_noop_trailing_brace(src):
Repository: asottile/add-trailing-comma

Issue:
Tool may change variables from type `T` to `tuple[T]`
Hey, I found this while using this as a pre-commit hook (big fan of the the project & your tools btw! :)).

It seems the tool may change turn a type into a tuple[type] in a situation like this;
```py
x = (
    object  # < comma is added here
), object
```

Comments:

Patch:
diff --git a/add_trailing_comma/_plugins/literals.py b/add_trailing_comma/_plugins/literals.py
index c5771be..53bdcf6 100644
--- a/add_trailing_comma/_plugins/literals.py
+++ b/add_trailing_comma/_plugins/literals.py
@@ -26,12 +26,11 @@ def _fix_literal(
         *,
         one_el_tuple: bool,
 ) -> None:
-    if tokens[i].src in START_BRACES:  # pragma: no branch (<py38)
-        fix_brace(
-            tokens, find_simple(i, tokens),
-            add_comma=True,
-            remove_comma=not one_el_tuple,
-        )
+    fix_brace(
+        tokens, find_simple(i, tokens),
+        add_comma=True,
+        remove_comma=not one_el_tuple,
+    )
 
 
 @register(ast.Set)
@@ -90,6 +89,27 @@ def _fix_tuple(
     )
 
 
+def _fix_tuple_py38(
+        i: int,
+        tokens: List[Token],
+        *,
+        one_el_tuple: bool,
+) -> None:  # pragma: no cover (<py38)
+    if tokens[i].src in START_BRACES:
+        fix = find_simple(i, tokens)
+
+        # for tuples we *must* find a comma, otherwise it is not a tuple
+        if fix is None or not fix.multi_arg:
+            return
+
+        fix_brace(
+            tokens,
+            fix,
+            add_comma=True,
+            remove_comma=not one_el_tuple,
+        )
+
+
 @register(ast.Tuple)
 def visit_Tuple(
         state: State,
@@ -105,5 +125,5 @@ def visit_Tuple(
             func = functools.partial(_fix_tuple, one_el_tuple=is_one_el)
             yield ast_to_offset(node), func
         else:  # pragma: no cover (py38+)
-            func = functools.partial(_fix_literal, one_el_tuple=is_one_el)
+            func = functools.partial(_fix_tuple_py38, one_el_tuple=is_one_el)
             yield ast_to_offset(node), func


Test patch:
diff --git a/tests/features/literals_test.py b/tests/features/literals_test.py
index 74f543e..f5dda44 100644
--- a/tests/features/literals_test.py
+++ b/tests/features/literals_test.py
@@ -15,6 +15,12 @@ from add_trailing_comma._main import _fix_src
         '    pass\n'
         '[x] = {y}',
         pytest.param('x[1, 2, 3, 4]', id='multi-slice'),
+        pytest.param(
+            'x = (\n'
+            '    object\n'
+            '), object\n',
+            id='regression test for #153',
+        ),
     ),
 )
 def test_noop_literals(src):
Repository: asottile/add-trailing-comma

Issue:
AssertionError on valid syntax
```python
with a:  
    pass 
[b] = {1}
```

produces this error with add-trailing-comma version 0.5.1:

```
Traceback (most recent call last):
  File "/nail/home/ckuehl/.pre-commit/repo3dPrz7/py_env-python2.7/bin/add-trailing-comma", line 9, in <module>
    load_entry_point('add-trailing-comma==0.5.1', 'console_scripts', 'add-trailing-comma')()
  File "/nail/home/ckuehl/.pre-commit/repo3dPrz7/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 378, in main
    ret |= fix_file(filename, args)
  File "/nail/home/ckuehl/.pre-commit/repo3dPrz7/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 358, in fix_file
    contents_text = _fix_src(contents_text, args.py35_plus)
  File "/nail/home/ckuehl/.pre-commit/repo3dPrz7/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 333, in _fix_src
    fixes.append((True, _find_simple(i, tokens)))
  File "/nail/home/ckuehl/.pre-commit/repo3dPrz7/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 154, in _find_simple
    raise AssertionError('Past end?')
AssertionError: Past end
```

Comments:

Patch:
diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 926f9de..2e71af5 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -325,6 +325,9 @@ def _fix_src(contents_text, py35_plus, py36_plus):
 
     tokens = src_to_tokens(contents_text)
     for i, token in _changing_list(tokens):
+        # DEDENT is a zero length token
+        if not token.src:
+            continue
         key = Offset(token.line, token.utf8_byte_offset)
 
         fixes = []


Test patch:
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index 82e51eb..a370743 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -149,9 +149,13 @@ def test_fixes_calls(src, expected):
         '[1, 2, 3, 4]',
         '{1, 2, 3, 4}',
         '{1: 2, 3: 4}',
+        # Regression test for #26
+        'if True:\n'
+        '    pass\n'
+        '[x] = {y}',
     ),
 )
-def test_noop_one_line_literals(src):
+def test_noop_literals(src):
     assert _fix_src(src, py35_plus=False, py36_plus=False) == src
Repository: asottile/add-trailing-comma

Issue:
autopep8 and add-trailing-comma fight over indentation
Here's an (admittedly poorly-formatted) reproduction. FWIW I prefer add-trailing-comma's approach, but curious to hear your thoughts. This is obviously weird indentation but ideally they wouldn't fight. Do we need to make autopep8 smarter?

## what add-trailing-comma wants
```python
[a()
    for b in c
    if (
        d
    )
]
```

## what autopep8 wants
```python
[a()
    for b in c
    if (
        d
)
]
```

Comments:

Patch:
diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 006dfe8..846894c 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -341,11 +341,11 @@ def _fix_src(contents_text, py35_plus, py36_plus):
             add_comma = not func.star_args or py36_plus
             # functions can be treated as calls
             fixes.append((add_comma, _find_call(func, i, tokens)))
-        # Handle parenthesized things
-        elif token.src == '(':
-            fixes.append((False, _find_simple(i, tokens)))
         elif key in visitor.literals:
             fixes.append((True, _find_simple(i, tokens)))
+        # Handle parenthesized things, unhug of tuples, and comprehensions
+        elif token.src in START_BRACES:
+            fixes.append((False, _find_simple(i, tokens)))
 
         for add_comma, fix_data in fixes:
             if fix_data is not None:


Test patch:
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index a663f99..ff4a4a8 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -577,6 +577,23 @@ def test_noop_unhugs(src):
             '    ], None,\n'
             ')',
         ),
+        # Regression test for #32
+        (
+            '[a()\n'
+            '    for b in c\n'
+            '    if (\n'
+            '        d\n'
+            '    )\n'
+            ']',
+
+            '[\n'
+            '    a()\n'
+            '    for b in c\n'
+            '    if (\n'
+            '        d\n'
+            '    )\n'
+            ']',
+        ),
     ),
 )
 def test_fix_unhugs(src, expected):
Repository: asottile/add-trailing-comma

Issue:
False negative with statement ending with parens
```python
if (foo and
    bar()):
    pass
```

I expect to be rewritten to

```python
if (
    foo and
    bar()
):
    pass
```

But I imagine the same code that prevents this from being rewritten is firing:

```python
foo('bar {}'.format(
    'baz',
))
```

which I don't think should be rewritten.

Need to come up with a more clever heuristic here.

Comments:

Patch:
diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 9eaa33f..34e1012 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -271,7 +271,7 @@ def _fix_brace(fix_data, add_comma, tokens):
             # Don't unhug single element things with a multi-line component
             # inside.
             not fix_data.multi_arg and
-            hug_open and
+            tokens[first_brace + 1].src in START_BRACES and
             tokens[last_brace - 1].src in END_BRACES or
             # Don't unhug when containing a single token (such as a triple
             # quoted string).


Test patch:
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index fa4593d..9fde7b4 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -594,6 +594,17 @@ def test_noop_unhugs(src):
             '    )\n'
             ']',
         ),
+        pytest.param(
+            'x = [x\n'
+            '     for x in y()]\n',
+
+            'x = [\n'
+            '    x\n'
+            '    for x in y()\n'
+            ']\n',
+
+            id='#42: listcomp unhug ends in brace',
+        ),
     ),
 )
 def test_fix_unhugs(src, expected):
Repository: asottile/all-repos

Issue:
Cloning does not work for GitHub Enterprise installations with custom domain
Looks like `github.com` is hardcoded in the repo url:

https://github.com/asottile/all-repos/blob/651ab491d1c3a799f677c107c2edde561364c013/all_repos/github_api.py#L52

I could get the command to work by changing this to my custom domain name.

Am I doing something wrong? We should add an option to allow setting this?

Comments:

Patch:
diff --git a/all_repos/github_api.py b/all_repos/github_api.py
index b55f91c..2ac931d 100644
--- a/all_repos/github_api.py
+++ b/all_repos/github_api.py
@@ -44,12 +44,19 @@ def get_all(url: str, **kwargs: Any) -> List[Dict[str, Any]]:
     return ret
 
 
+def _strip_trailing_dot_git(ssh_url: str) -> str:
+    if ssh_url.endswith('.git'):
+        return ssh_url[:-1 * len('.git')]
+    else:
+        return ssh_url
+
+
 def filter_repos(
         repos: List[Dict[str, Any]], *,
         forks: bool, private: bool, collaborator: bool, archived: bool,
 ) -> Dict[str, str]:
     return {
-        repo['full_name']: 'git@github.com:{}'.format(repo['full_name'])
+        repo['full_name']: _strip_trailing_dot_git(repo['ssh_url'])
         for repo in repos
         if (
             (forks or not repo['fork']) and


Test patch:
diff --git a/tests/github_api_test.py b/tests/github_api_test.py
index 4eff101..a87d06e 100644
--- a/tests/github_api_test.py
+++ b/tests/github_api_test.py
@@ -1,5 +1,6 @@
 import pytest
 
+from all_repos.github_api import _strip_trailing_dot_git
 from all_repos.github_api import better_repr
 from all_repos.github_api import get_all
 from testing.mock_http import FakeResponse
@@ -52,3 +53,25 @@ def test_get_all(mock_urlopen):
 
     ret = get_all('https://example.com/api')
     assert ret == ['page1_1', 'page1_2', 'page2_1', 'page2_2', 'page3_1']
+
+
+@pytest.mark.parametrize(
+    ('val', 'expected'),
+    (
+        ('', ''),
+        (
+            'git@github.com:sass/libsass-python',
+            'git@github.com:sass/libsass-python',
+        ),
+        (
+            'git@github.com:sass/libsass-python.git',
+            'git@github.com:sass/libsass-python',
+        ),
+        (
+            'git@github.com:.git/example',
+            'git@github.com:.git/example',
+        ),
+    ),
+)
+def test_strip_trailing_dot_git(val, expected):
+    assert _strip_trailing_dot_git(val) == expected
Repository: asottile/all-repos

Issue:
Support creating draft PRs for AzDO
Hey, I successfully configured the tool to run with Azure DevOps, but I noticed that config included in the repo always causes creating standard PRs. In my organization, a standard PR automatically triggers CI, so it creates high queues for CI agents when a lot of PRs are created.

For me, the simplest solution was to create draft PRs instead. AzDO supports `isDraft` parameter in the API call ([docs](https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/create?view=azure-devops-rest-6.0)), so I did a minimal change in #322, and it seems to be working fine after adding `"draft": true` in `"push_settings"` in all-repos JSON config.

I thought that it might be useful for somebody out there, hence this issue and PR. Shall we merge it?

Comments:

Patch:
diff --git a/all_repos/push/azure_repos_pull_request.py b/all_repos/push/azure_repos_pull_request.py
index 4d1e075..58d71e8 100644
--- a/all_repos/push/azure_repos_pull_request.py
+++ b/all_repos/push/azure_repos_pull_request.py
@@ -19,6 +19,7 @@ class Settings(NamedTuple):
     base_url: str = 'https://dev.azure.com'
     api_key: str | None = None
     api_key_env: str | None = None
+    draft: bool = False
 
     def __repr__(self) -> str:
         return hide_api_key_repr(self)
@@ -53,6 +54,7 @@ def make_pull_request(
         'description': body.decode().strip(),
         'sourceRefName': f'refs/heads/{head}',
         'targetRefName': f'refs/heads/{autofix_lib.target_branch()}',
+        'isDraft': settings.draft,
     }).encode()
 
     pull_request_url = (


Test patch:
diff --git a/tests/push/azure_repos_pull_request_test.py b/tests/push/azure_repos_pull_request_test.py
index c36c400..b993a97 100644
--- a/tests/push/azure_repos_pull_request_test.py
+++ b/tests/push/azure_repos_pull_request_test.py
@@ -82,5 +82,6 @@ def test_settings_repr():
         "    base_url='https://dev.azure.com',\n"
         '    api_key=...,\n'
         '    api_key_env=None,\n'
+        '    draft=False,\n'
         ')'
     )
Repository: asottile/all-repos

Issue:
Allow a "read only" mode where `push_settings` are optional
Basically make the configuration lazily load the various parts for pushing / pulling

This would enable one to make a r/o all-repos

I guess this could just be implemented as a builtin `noop` push and then:

```json
    "push": "all_repos.push.noop",
    "push_settings": {}
```

Comments:

Patch:
diff --git a/README.md b/README.md
index 821c955..35f0218 100644
--- a/README.md
+++ b/README.md
@@ -362,6 +362,14 @@ branch.
   to the upstream repository.
 
 
+### `all_repos.push.readonly`
+
+Does nothing.
+
+#### `push_settings`
+
+There are no configurable settings for `readonly`.
+
 ## Writing your own push module
 
 First create a module.  This module must have the following api:
diff --git a/all_repos/push/readonly.py b/all_repos/push/readonly.py
new file mode 100644
index 0000000..d74af6b
--- /dev/null
+++ b/all_repos/push/readonly.py
@@ -0,0 +1,7 @@
+import collections
+
+Settings = collections.namedtuple('Settings', ())
+
+
+def push(settings: Settings, branch_name: str) -> None:
+    return None


Test patch:
diff --git a/tests/push/readonly_test.py b/tests/push/readonly_test.py
new file mode 100644
index 0000000..eaba410
--- /dev/null
+++ b/tests/push/readonly_test.py
@@ -0,0 +1,6 @@
+from all_repos.push import readonly
+
+
+def test_does_not_fire_missiles():
+    # does nothing, assert it doesn't crash
+    readonly.push(readonly.Settings(), 'branch')
Repository: asottile/astpretty

Issue:
Have an option for indent argument to be number of spaces
Like `json.dumps` or `ast.dump`, making indent have an option to be an integer would be nice.

I could probably make a PR for this, if the idea gets approval.

Comments:

Patch:
diff --git a/astpretty.py b/astpretty.py
index d0c1b59..abc8444 100644
--- a/astpretty.py
+++ b/astpretty.py
@@ -75,7 +75,7 @@ def _leaf(node: 'ASTType', show_offsets: bool = True) -> str:
 
 def pformat(
         node: Union['ASTType', None, str],
-        indent: str = '    ',
+        indent: Union[str, int] = '    ',
         show_offsets: bool = True,
         _indent: int = 0,
 ) -> str:
@@ -86,6 +86,11 @@ def pformat(
     elif _is_leaf(node):
         return _leaf(node, show_offsets=show_offsets)
     else:
+        if isinstance(indent, int):
+            indent_s = indent * ' '
+        else:
+            indent_s = indent
+
         class state:
             indent = _indent
 
@@ -96,7 +101,7 @@ def pformat(
             state.indent -= 1
 
         def indentstr() -> str:
-            return state.indent * indent
+            return state.indent * indent_s
 
         def _pformat(el: Union['ASTType', None, str], _indent: int = 0) -> str:
             return pformat(


Test patch:
diff --git a/tests/astpretty_test.py b/tests/astpretty_test.py
index b595d64..796950f 100644
--- a/tests/astpretty_test.py
+++ b/tests/astpretty_test.py
@@ -127,6 +127,21 @@ def test_pformat_custom_indent():
     )
 
 
+def test_pformat_integer_indent():
+    node = _to_expr_value('[a, b, c]')
+    ret = astpretty.pformat(node, indent=3, show_offsets=False)
+    assert ret == (
+        'List(\n'
+        '   elts=[\n'
+        "      Name(id='a', ctx=Load()),\n"
+        "      Name(id='b', ctx=Load()),\n"
+        "      Name(id='c', ctx=Load()),\n"
+        '   ],\n'
+        '   ctx=Load(),\n'
+        ')'
+    )
+
+
 def test_pformat_nested_node_without_line_information():
     expected_38 = (
         'Subscript(\n'
Repository: asottile/babi

Issue:
utilize identify's shebang detection for grammar when possible
an example:

```python
#!/usr/bin/env python3
print('hello')
```

this file saved as `foo/install` gets highlighted incorrectly as shell, but we can utilize `tags_from_path` to identify this as `python` earlier on

Comments:

Patch:
diff --git a/babi/highlight.py b/babi/highlight.py
index cbd2f75..284ac53 100644
--- a/babi/highlight.py
+++ b/babi/highlight.py
@@ -10,6 +10,7 @@ from typing import Tuple
 from typing import TypeVar
 
 from identify.identify import tags_from_filename
+from identify.identify import tags_from_path
 
 from babi._types import Protocol
 from babi.fdict import FChainMap
@@ -721,7 +722,11 @@ class Grammars:
         return self.compiler_for_scope('source.unknown')
 
     def compiler_for_file(self, filename: str, first_line: str) -> Compiler:
-        for tag in tags_from_filename(filename) - {'text'}:
+        try:
+            tags = tags_from_path(filename)
+        except ValueError:
+            tags = tags_from_filename(filename)
+        for tag in tags - {'text'}:
             try:
                 # TODO: this doesn't always match even if we detect it
                 return self.compiler_for_scope(f'source.{tag}')


Test patch:
diff --git a/tests/highlight_test.py b/tests/highlight_test.py
index db8d2b7..3a72e5a 100644
--- a/tests/highlight_test.py
+++ b/tests/highlight_test.py
@@ -1,5 +1,7 @@
 from __future__ import annotations
 
+import stat
+
 import pytest
 
 from babi.highlight import highlight_line
@@ -13,6 +15,17 @@ def test_grammar_matches_extension_only_name(make_grammars):
     assert compiler.root_state.entries[0].scope[0] == 'shell'
 
 
+def test_file_without_extension(tmpdir, make_grammars):
+    f = tmpdir.join('f')
+    f.write('#!/usr/bin/env python3')
+    f.chmod(stat.S_IRWXU)
+
+    data = {'scopeName': 'source.python', 'patterns': []}
+    grammars = make_grammars(data)
+    compiler = grammars.compiler_for_file(str(f), f.read())
+    assert compiler.root_state.entries[0].scope[0] == 'source.python'
+
+
 def test_grammar_matches_via_identify_tag(make_grammars):
     grammars = make_grammars({'scopeName': 'source.ini', 'patterns': []})
     compiler = grammars.compiler_for_file('setup.cfg', '')
Repository: asottile/babi

Issue:
pre-commit runs with the wrong configuration when accessing a file in a different repository
went through all the trouble to check the right config exists here: https://github.com/asottile/babi/blob/5cf5f2501c90274e7f640ff0ad4dfb355631b960/babi/linters/pre_commit.py#L66

but then didn't bother actually using it here: https://github.com/asottile/babi/blob/5cf5f2501c90274e7f640ff0ad4dfb355631b960/babi/linters/pre_commit.py#L69

Comments:

Patch:
diff --git a/babi/linters/pre_commit.py b/babi/linters/pre_commit.py
index d5ffc5c..380608b 100644
--- a/babi/linters/pre_commit.py
+++ b/babi/linters/pre_commit.py
@@ -63,10 +63,16 @@ class PreCommit:
             return None  # not in a git repo!
 
         # no pre-commit config!
-        if not os.path.exists(os.path.join(root, '.pre-commit-config.yaml')):
+        cfg = os.path.join(root, '.pre-commit-config.yaml')
+        if not os.path.exists(cfg):
             return None
 
-        return ('pre-commit', 'run', '--color=never', '--files', filename)
+        return (
+            'pre-commit', 'run',
+            '--color=never',
+            '--config', cfg,
+            '--files', filename,
+        )
 
     def parse(self, filename: str, output: str) -> tuple[linting.Error, ...]:
         root = self._root(filename)


Test patch:
diff --git a/tests/linters/pre_commit_test.py b/tests/linters/pre_commit_test.py
index 6fdf20a..7fa7781 100644
--- a/tests/linters/pre_commit_test.py
+++ b/tests/linters/pre_commit_test.py
@@ -96,10 +96,16 @@ def test_command_returns_none_no_pre_commit_config(tmpdir_git):
 
 
 def test_command_returns_when_config_exists(tmpdir_git):
-    tmpdir_git.join('.pre-commit-config.yaml').write('{}\n')
+    cfg = tmpdir_git.join('.pre-commit-config.yaml')
+    cfg.write('{}\n')
     path = str(tmpdir_git.join('t.py'))
     ret = PreCommit().command(path, 'source.python')
-    assert ret == ('pre-commit', 'run', '--color=never', '--files', path)
+    assert ret == (
+        'pre-commit', 'run',
+        '--color=never',
+        '--config', str(cfg),
+        '--files', path,
+    )
 
 
 def test_filters_file_paths_to_actual_file(tmpdir_git):