Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Change error code prefix to DAR.
Browse files Browse the repository at this point in the history
Error codes reported to Flake8 have to have a unique prefix.  The
previous error code prefixes, "S" and "I" collided with some other
linters.  Switching to a three-letter prefix should resolve this.

Resolves: Issue #40.
  • Loading branch information
terrencepreilly committed Sep 29, 2019
1 parent 41f4f70 commit 9018557
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [1.0.0-alpha.2] - 2019-09-29

### Changed

- Changed the error code prefixes from "I" and "S" to "DAR". This
will prevent collisions with other utilities reported through flake8.
See Issue #40.

### Fixed

- UTF-8 encoded source files were not working previously. Rather than
Expand Down
35 changes: 17 additions & 18 deletions darglint/errors.py
Expand Up @@ -5,9 +5,8 @@
definition.
Groups of errors:
I Interface
S Style
000 Style
100 Args
200 Returns
300 Yields
Expand All @@ -18,7 +17,7 @@
pycodestyle package. Interface, here, describes incorrect or incomplete
documentation. Style, here, means errors in documentation style.
So, for instance, missing a parameter in the documentation would be
I101.
DAR101.
"""
import ast # noqa: F401
Expand Down Expand Up @@ -105,7 +104,7 @@ def __init__(self, function, line_numbers=None):
class GenericSyntaxError(DarglintError):
"""Describes that something went wrong in parsing the docstring."""

error_code = 'S001'
error_code = 'DAR001'

def __init__(self, function, message, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand All @@ -129,7 +128,7 @@ def __init__(self, function, message, line_numbers=None):
class EmptyDescriptionError(DarglintError):
"""Describes when an argument/exception lacks a description."""

error_code = 'S002'
error_code = 'DAR002'

def __init__(self, function, message, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand All @@ -155,7 +154,7 @@ class IndentError(DarglintError):
"""Describes when a line is under-indented or over-indented.
"""

error_code = 'S003'
error_code = 'DAR003'

def __init__(self, function, line_numbers=None):
# type: (ast.FunctionDef, Tuple[int, int]) -> None
Expand All @@ -178,7 +177,7 @@ def __init__(self, function, line_numbers=None):
class ExcessNewlineError(DarglintError):
"""Describes when a docstring has an extra newline where it shouldn't."""

error_code = 'S004'
error_code = 'DAR004'

def __init__(self, function, line_numbers=None):
# type: (ast.FunctionDef, Tuple[int, int]) -> None
Expand All @@ -193,7 +192,7 @@ def __init__(self, function, line_numbers=None):
class MissingParameterError(DarglintError):
"""Describes when a docstring is missing a parameter in the definition."""

error_code = 'I101'
error_code = 'DAR101'

def __init__(self, function, name, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand All @@ -216,7 +215,7 @@ def __init__(self, function, name, line_numbers=None):
class ExcessParameterError(DarglintError):
"""Describes when a docstring contains a parameter not in function."""

error_code = 'I102'
error_code = 'DAR102'

def __init__(self, function, name, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand All @@ -239,7 +238,7 @@ def __init__(self, function, name, line_numbers=None):
class ParameterTypeMismatchError(DarglintError):
"""Describes when a docstring parameter type doesn't match function."""

error_code = 'I103'
error_code = 'DAR103'

def __init__(self, function, name, expected, actual, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, str, str, Tuple[int, int]) -> None
Expand Down Expand Up @@ -271,7 +270,7 @@ def __init__(self, function, name, expected, actual, line_numbers=None):
class MissingReturnError(DarglintError):
"""Describes when a docstring is missing a return from definition."""

error_code = 'I201'
error_code = 'DAR201'

def __init__(self, function, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], Tuple[int, int]) -> None
Expand All @@ -294,7 +293,7 @@ def __init__(self, function, line_numbers=None):
class ExcessReturnError(DarglintError):
"""Describes when a docstring has a return not in definition."""

error_code = 'I202'
error_code = 'DAR202'

def __init__(self, function, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], Tuple[int, int]) -> None
Expand All @@ -317,7 +316,7 @@ def __init__(self, function, line_numbers=None):
class ReturnTypeMismatchError(DarglintError):
"""Describes when a docstring parameter type doesn't match function."""

error_code = 'I203'
error_code = 'DAR203'

def __init__(self, function, expected, actual, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, str, Tuple[int, int]) -> None
Expand Down Expand Up @@ -346,7 +345,7 @@ def __init__(self, function, expected, actual, line_numbers=None):
class MissingYieldError(DarglintError):
"""Describes when a docstring is missing a yield present in definition."""

error_code = 'I301'
error_code = 'DAR301'

def __init__(self, function, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], Tuple[int, int]) -> None
Expand All @@ -369,7 +368,7 @@ def __init__(self, function, line_numbers=None):
class ExcessYieldError(DarglintError):
"""Describes when a docstring has a yield not in definition."""

error_code = 'I302'
error_code = 'DAR302'

def __init__(self, function, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], Tuple[int, int]) -> None
Expand All @@ -392,7 +391,7 @@ def __init__(self, function, line_numbers=None):
class MissingRaiseError(DarglintError):
"""Describes when a docstring is missing an exception raised."""

error_code = 'I401'
error_code = 'DAR401'

def __init__(self, function, name, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand Down Expand Up @@ -423,7 +422,7 @@ class ExcessRaiseError(DarglintError):
"""

error_code = 'I402'
error_code = 'DAR402'

def __init__(self, function, name, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand All @@ -447,7 +446,7 @@ def __init__(self, function, name, line_numbers=None):
class ExcessVariableError(DarglintError):
"""Describes when a docstring describes a variable which is not defined."""

error_code = 'I501'
error_code = 'DAR501'

def __init__(self, function, name, line_numbers=None):
# type: (Union[ast.FunctionDef, ast.AsyncFunctionDef], str, Tuple[int, int]) -> None
Expand Down
24 changes: 12 additions & 12 deletions tests/test_integrity_checker.py
Expand Up @@ -377,7 +377,7 @@ def test_noqa_after_excess_raises(self):
' """Raise an error.',
'',
' Raises:',
' Exception: In all cases. # noqa: I402',
' Exception: In all cases. # noqa: DAR402',
'',
' """',
' pass',
Expand All @@ -389,7 +389,7 @@ def test_noqa_for_missing_raises(self):
'def some_function():',
' """No problems.',
'',
' # noqa: I401 Exception',
' # noqa: DAR401 Exception',
'',
' """',
' raise Exception("No, actually there are problems.")',
Expand All @@ -402,7 +402,7 @@ def test_noqa_for_excess_parameters(self):
' """Excess arguments.',
'',
' Args:',
' x: Will be here eventually. # noqa: I102',
' x: Will be here eventually. # noqa: DAR102',
'',
' """',
' pass'
Expand All @@ -414,7 +414,7 @@ def test_noqa_for_missing_parameters(self):
'def function_with_missing_parameter(x, y):',
' """We\'re missing a description of x, y.',
'',
' # noqa: I101',
' # noqa: DAR101',
'',
' """',
' print(x / 2)',
Expand All @@ -426,7 +426,7 @@ def test_noqa_missing_return_parameter_added(self):
'def function_without_return():',
' """This should have a return in the docstring.',
'',
' # noqa: I201',
' # noqa: DAR201',
'',
' """',
' global bad_number',
Expand All @@ -442,7 +442,7 @@ def test_noqa_excess_return(self):
' Returns:',
' Some value yet to be determined.',
'',
' # noqa: I202',
' # noqa: DAR202',
'',
' """',
' pass',
Expand All @@ -454,7 +454,7 @@ def test_noqa_for_missing_yield(self):
'def funtion_with_yield():',
' """This should have a yields section.',
'',
' # noqa: I301',
' # noqa: DAR301',
'',
' """',
' yield 3',
Expand All @@ -469,7 +469,7 @@ def test_noqa_for_excess_yield(self):
' Yields:',
' A number.',
'',
' # noqa: I302',
' # noqa: DAR302',
'',
' """',
' print(\'Doesnt yield\')',
Expand All @@ -487,7 +487,7 @@ def test_noqa_for_parameter_type_mismatch(self):
' Returns:',
' float: The square root',
'',
' # noqa: I103',
' # noqa: DAR103',
'',
' """',
' return x ** 0.5',
Expand All @@ -506,7 +506,7 @@ def test_noqa_for_parameter_type_mismatch_by_name(self):
' Returns:',
' float: The square root',
'',
' # noqa: I103 x',
' # noqa: DAR103 x',
'',
' """',
' return x ** 0.5',
Expand All @@ -524,7 +524,7 @@ def test_noqa_for_return_type_mismatch(self):
' Returns:',
' list: The updated dictionary.',
'',
' # noqa: I203',
' # noqa: DAR203',
'',
' """',
' x.update({"data": 3})',
Expand Down Expand Up @@ -641,7 +641,7 @@ def test_global_noqa_works_for_syntax_errors(self):
' """',
' pass',
])
for variant in ['# noqa: *', '# noqa: S001', '# noqa']:
for variant in ['# noqa: *', '# noqa: DAR001', '# noqa']:
self.has_no_errors(program.format(variant))


Expand Down

0 comments on commit 9018557

Please sign in to comment.