Skip to content

Commit

Permalink
Remove pylint annotations from source code
Browse files Browse the repository at this point in the history
  • Loading branch information
jherland committed May 6, 2024
1 parent 8b23a78 commit 619f4fb
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 33 deletions.
6 changes: 3 additions & 3 deletions fawltydeps/extract_declared_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

if sys.version_info >= (3, 11):
import tomllib # pylint: disable=E1101
import tomllib
else:
import tomli as tomllib

Expand Down Expand Up @@ -99,7 +99,7 @@ def _extract_deps_from_setup_call( # noqa: C901
yield parse_one_req(item, source)
except (DependencyParsingError, CannotResolve) as exc:
if sys.version_info >= (3, 9):
unparsed_content = ast.unparse(exc.node) # pylint: disable=E1101
unparsed_content = ast.unparse(exc.node)
else:
unparsed_content = ast.dump(exc.node)
logger.warning(
Expand Down Expand Up @@ -153,7 +153,7 @@ def parse_value(value: str) -> Iterator[DeclaredDependency]:
# See: https://github.com/nexB/pip-requirements-parser/pull/17

# https://github.com/nexB/pip-requirements-parser/pull/19#discussion_r1379279880
temp_file = NamedTemporaryFile( # pylint: disable=consider-using-with
temp_file = NamedTemporaryFile(
"wt",
delete=False,
# we prefer utf8 encoded strings, but ...
Expand Down
2 changes: 1 addition & 1 deletion fawltydeps/gitignore_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from fawltydeps.types import Location

if TYPE_CHECKING or sys.version_info >= (3, 9):
CompiledRegex = re.Pattern[str] # pylint: disable=unsubscriptable-object
CompiledRegex = re.Pattern[str]
else: # re.Pattern not subscriptable before Python 3.9
CompiledRegex = re.Pattern

Expand Down
2 changes: 1 addition & 1 deletion fawltydeps/limited_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, source: Location) -> None:
def _show(self, node: ast.AST) -> str:
"""Human-readable representation of this node, mostly for debug logs."""
if sys.version_info >= (3, 9):
code = ast.unparse(node) # pylint: disable=no-member
code = ast.unparse(node)
else:
code = "<code>"
return f"{code} @ {self.source.supply(lineno=node.lineno)}"
Expand Down
12 changes: 6 additions & 6 deletions fawltydeps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
UNUSED_DEPS_OUTPUT_PREFIX = "These dependencies appear to be unused (i.e. not imported)"


class Analysis: # pylint: disable=too-many-instance-attributes
class Analysis:
"""Result from FawltyDeps analysis, to be presented to the user.
This collects the various data structures that are central to FawltyDeps'
Expand Down Expand Up @@ -185,15 +185,15 @@ def create(cls, settings: Settings, stdin: Optional[BinaryIO] = None) -> Analysi

# Compute only the properties needed to satisfy settings.actions:
if ret.is_enabled(Action.LIST_SOURCES):
ret.sources # pylint: disable=pointless-statement # noqa: B018
ret.sources # noqa: B018
if ret.is_enabled(Action.LIST_IMPORTS):
ret.imports # pylint: disable=pointless-statement # noqa: B018
ret.imports # noqa: B018
if ret.is_enabled(Action.LIST_DEPS):
ret.declared_deps # pylint: disable=pointless-statement # noqa: B018
ret.declared_deps # noqa: B018
if ret.is_enabled(Action.REPORT_UNDECLARED):
ret.undeclared_deps # pylint: disable=pointless-statement # noqa: B018
ret.undeclared_deps # noqa: B018
if ret.is_enabled(Action.REPORT_UNUSED):
ret.unused_deps # pylint: disable=pointless-statement # noqa: B018
ret.unused_deps # noqa: B018

return ret

Expand Down
2 changes: 1 addition & 1 deletion fawltydeps/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from fawltydeps.utils import calculated_once, site_packages

if sys.version_info >= (3, 11):
import tomllib # pylint: disable=no-member
import tomllib
else:
import tomli as tomllib

Expand Down
4 changes: 2 additions & 2 deletions fawltydeps/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from fawltydeps.types import CustomMapping, ParserChoice, PathOrSpecial, TomlData

if sys.version_info >= (3, 11):
import tomllib # pylint: disable=no-member
import tomllib
else:
import tomli as tomllib

Expand Down Expand Up @@ -192,7 +192,7 @@ def customise_sources(
cls,
init_settings: SettingsSourceCallable,
env_settings: SettingsSourceCallable,
file_secret_settings: SettingsSourceCallable, # pylint: disable=W0613 # noqa: ARG003
file_secret_settings: SettingsSourceCallable, # noqa: ARG003
) -> Tuple[SettingsSourceCallable, ...]:
"""Select and prioritize the various configuration sources."""
# Use class vars in Settings to determine which configuration file
Expand Down
2 changes: 1 addition & 1 deletion fawltydeps/traverse_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]


def find_sources( # pylint: disable=too-many-branches,too-many-statements # noqa: C901, PLR0912, PLR0915
def find_sources( # noqa: C901, PLR0912, PLR0915
settings: Settings,
source_types: AbstractSet[Type[Source]] = frozenset(
[CodeSource, DepsSource, PyEnvSource]
Expand Down
2 changes: 1 addition & 1 deletion fawltydeps/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from fawltydeps.utils import hide_dataclass_fields

if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-member
from typing import Literal
else:
from typing_extensions import Literal

Expand Down
2 changes: 1 addition & 1 deletion tests/project_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from fawltydeps.types import TomlData

if sys.version_info >= (3, 11):
import tomllib # pylint: disable=E1101
import tomllib
else:
import tomli as tomllib

Expand Down
4 changes: 0 additions & 4 deletions tests/test_deps_parser_determination.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def test_explicit_parse_strategy__mismatch_yields_appropriate_logging(
]
],
)
# pylint: disable=unused-argument
def test_filepath_inference(
tmp_path,
project_with_setup_with_cfg_pyproject_and_requirements, # noqa: ARG001
Expand Down Expand Up @@ -141,7 +140,6 @@ def test_filepath_inference(
]
],
)
# pylint: disable=unused-argument
def test_extract_from_directory_applies_manual_parser_choice_iff_choice_applies(
tmp_path,
project_with_setup_with_cfg_pyproject_and_requirements, # noqa: ARG001
Expand Down Expand Up @@ -181,8 +179,6 @@ def test_extract_from_directory_applies_manual_parser_choice_iff_choice_applies(
]
],
)
# pylint: disable=unused-argument
# pylint: disable=too-many-arguments
def test_extract_from_file_applies_manual_choice_even_if_mismatched(
caplog,
tmp_path,
Expand Down
13 changes: 3 additions & 10 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from fawltydeps.types import TomlData

if sys.version_info >= (3, 11):
from tomllib import TOMLDecodeError # pylint: disable=no-member
from tomllib import TOMLDecodeError
else:
from tomli import TOMLDecodeError

Expand Down Expand Up @@ -241,10 +241,7 @@ def test_multivalued_options_are_aggregated_correctly(optargs):

@pytest.mark.parametrize(
"optname",
{
act.dest
for act in build_parser()._actions # pylint: disable=protected-access # noqa: SLF001
}
{act.dest for act in build_parser()._actions} # noqa: SLF001
& set(Settings.__fields__.keys()),
)
def test_settings_members_are_absent_from_namespace_if_not_provided_at_cli(optname):
Expand Down Expand Up @@ -457,11 +454,7 @@ class SettingsTestVector:
@pytest.mark.parametrize(
"vector", [pytest.param(v, id=v.id) for v in settings_tests_samples]
)
def test_settings(
vector,
setup_fawltydeps_config,
setup_env,
): # pylint: disable=too-many-arguments
def test_settings(vector, setup_fawltydeps_config, setup_env):
config_file = (
None if vector.config is None else setup_fawltydeps_config(vector.config)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_location__hashable_and_unique():
# equal, i.e. that Location instances constructed from the same args
# are considered equal.
test_dict = {Location(*args): True for args, *_ in testdata.values()}
for args, *_ in testdata.values(): # pylint: disable=unbalanced-dict-unpacking
for args, *_ in testdata.values():
loc = Location(*args)
test_dict[loc] = loc # reset {loc: True} to {loc: loc}

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def run_fawltydeps_function(


@dataclass
class FDTestVector: # pylint: disable=too-many-instance-attributes
class FDTestVector:
"""Test vectors for various parts of the FawltyDeps core logic."""

id: str
Expand Down

0 comments on commit 619f4fb

Please sign in to comment.