Skip to content
This repository was archived by the owner on Oct 30, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shopify_python/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ def handle_message(self, msg):

def pylint_files(files, **kwargs):
# type: (typing.List[str], **str) -> typing.Iterable[utils.Message]
# File paths must not be interpreted as Pylint options.
for path in files:
if path.startswith('-'):
raise ValueError("refusing to lint path that looks like a pylint option: {}".format(path))

kwargs['reports'] = 'n'
pylint_args = ["--{}={}".format(key, value) for key, value in kwargs.items()]

Expand Down
10 changes: 10 additions & 0 deletions tests/shopify_python/test_git_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import mock
import py # pylint: disable=unused-import
import pytest
import git # pylint: disable=unused-import
Expand Down Expand Up @@ -327,3 +328,12 @@ def test_passing_linter(tmpdir):

lint_results = [x for x in git_utils.pylint_files([str(tmpdir)], reports='n')]
assert lint_results == []


def test_linter_rejects_paths_that_look_like_options():
# type: () -> None
with mock.patch.object(git_utils.lint, 'Run') as pylint_run:
with pytest.raises(ValueError):
list(git_utils.pylint_files(['--example.py']))

pylint_run.assert_not_called()