Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def acknowledge_lint_errors(
exclude=exclude,
app_import_names=app_import_names,
extend_ignore=extend_ignore,
file_or_dir=file_or_dir,
file_or_dir=[bad_file],
excluded_errors=EXCLUDED_ERRORS,
)

Expand Down Expand Up @@ -128,7 +128,7 @@ def _handle_emergent_violations(exclude, app_import_names, extend_ignore, file_o
exclude=exclude,
app_import_names=app_import_names,
extend_ignore=extend_ignore,
file_or_dir=file_or_dir,
file_or_dir=[bad_file],
excluded_errors=EXCLUDED_ERRORS,
)
)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ line-length = 100

[tool.pytest.ini_options]
addopts = "--doctest-modules"
norecursedirs = "*__snapshots"
norecursedirs = "*__snapshots tests/*/input/*"


[tool.ni-python-styleguide]
extend_exclude = "*__snapshots/*/*input.py"
extend_exclude = "*__snapshots/*/*input.py,tests/*/input/*.py"


[build-system]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def method1():
return 7


def method2():
"""Provide an examples of doc strings that are too long.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "an examples" should be "an example"

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes switching all new instances of "Provide an examples" to "Provide an example"


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""
return 7 # Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


class Foo:
def __init__(self):
pass

def add(self, o):
"""Provide an examples of doc strings that are too long.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "an examples" should be "an example"

Suggested change
"""Provide an examples of doc strings that are too long.
"""Provide an example of doc strings that are too long.

Copilot uses AI. Check for mistakes.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""
return 7 # Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


class _PrivateFoo:
def __init__(self):
pass

def add(self, o):
"""Provide an examples of doc strings that are too long.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "an examples" should be "an example"

Copilot uses AI. Check for mistakes.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""
return 7 # Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""example of a python file with linter errors.
"""

import os

os.listdir()


def method_with_shadow_builtin(input):
"""Shadow a builtin."""
return input


def method_with_shadow_import(os):
"""Shadow an import."""
return os


def method_with_shadow_import_on_multiple_lines(
x,
y,
os,
):
"""Shadow an import."""
return os


def method_with_unused_param(unused_input):
"""Provide and unused param."""
return 5


def method_with_parameters_on_multiple_lines(x, y):
"""Provide parameters on multiple lines test case."""
return x + y


def method_with_bad_names_on_single_line(myBadlyNamedParam, my_other_Bad_name):
"""Provide parameters with bad names on single line."""
return myBadlyNamedParam + my_other_Bad_name


def method_with_bad_names_on_multiple_lines_1(
myBadlyNamedParam,
):
"""Provide parameters with bad names on multiple lines."""
return myBadlyNamedParam + 5


def method_with_bad_names_on_multiple_lines_2(
myBadlyNamedParam,
my_other_Bad_name,
):
"""Provide parameters with bad names on multiple lines."""
return myBadlyNamedParam + my_other_Bad_name


def method_withBadName_with_shadow(input):
"""Shadow a builtin."""
return input


def method_withBadName_with_unused_param(unused_input):
"""Provide and unused param."""
return 5


def method_withBadName_with_parameters_on_multiple_lines(x, y):
"""Provide parameters on multiple lines test case."""
return x + y


def method_withBadName_with_bad_params_on_single_line(myBadlyNamedParam, my_other_Bad_name):
"""Provide parameters with bad names on single line."""
return myBadlyNamedParam + my_other_Bad_name


def method_withBadName_with_bad_params_on_multiple_lines_1(
myBadlyNamedParam,
):
"""Provide parameters with bad names on multiple lines."""
return myBadlyNamedParam + 5


def method_withBadName_with_bad_params_on_multiple_lines_2(
myBadlyNamedParam,
my_other_Bad_name,
):
"""Provide parameters with bad names on multiple lines."""
return myBadlyNamedParam + my_other_Bad_name


def method_withBadName_andParams(my_normal_param, myBadlyNamedParam, my_other_Bad_param):
"""Provide example where black will want to split out result."""
return 5 + 7


def method_withBadName_and_bad_param_with_long_name(
my_normal_param, myBadlyNamedParam, my_other_Bad_param
):
"""Provide example where black will want to split out result even more"""
return 5 + 7
33 changes: 30 additions & 3 deletions tests/test_cli/test_acknowledge_existing_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import pytest

TEST_CASE_DIR = (
pathlib.Path(__file__).parent.absolute() / "acknowledge_existing_errors_test_cases__snapshots"
)
MODULE_DIR = pathlib.Path(__file__).parent.absolute()
TEST_CASE_DIR = MODULE_DIR / "acknowledge_existing_errors_test_cases__snapshots"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -73,3 +72,31 @@ def test_given_suppressed_file_linter_does_not_error(
output = styleguide_command(command="lint", command_args=[test_file, *additional_args])

assert output.exit_code in (True, 0), f"Error in running:\n{output.output}\n\n"


@pytest.mark.parametrize("cmd_args", [[], ["--aggressive"]], ids=["normal", "aggressive"])
def test_given_folder_with_multiple_files_linter_does_not_error(
cmd_args, tmp_path, styleguide_command, chdir
):
in_dir = MODULE_DIR / "acknowledge_existing_errors_multiple_files" / "input"
test_dir = tmp_path / "input"
shutil.copytree(in_dir, test_dir)
chdir(tmp_path)

output = styleguide_command(command="acknowledge-existing-violations", command_args=cmd_args)

assert output.exit_code in (True, 0), f"Error in running:\n{output}"


def test_given_folder_with_multiple_files_acknowledged__does_not_error(
tmp_path, styleguide_command, chdir
):
in_dir = MODULE_DIR / "acknowledge_existing_errors_multiple_files" / "input"
test_dir = tmp_path / "input"
shutil.copytree(in_dir, test_dir)
chdir(tmp_path)
styleguide_command(command="acknowledge-existing-violations", command_args=["--aggressive"])

output = styleguide_command(command="lint", command_args=[])

assert output.exit_code in (True, 0), f"Error in running:\n{output.output}\n\n"
Loading