From d1830418baf78297ca5def7ca6616c2014321e78 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 21:09:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pylint/checkers/__init__.py | 7 +- pylint/checkers/base/__init__.py | 13 +-- pylint/checkers/base/docstring_checker.py | 7 +- pylint/checkers/base/name_checker/__init__.py | 10 +-- pylint/checkers/base/name_checker/checker.py | 7 +- pylint/checkers/base_checker.py | 12 +-- pylint/checkers/classes/__init__.py | 3 +- pylint/checkers/classes/class_checker.py | 31 +++---- .../classes/special_methods_checker.py | 11 +-- pylint/checkers/format.py | 12 ++- pylint/checkers/imports.py | 10 +-- pylint/checkers/newstyle.py | 7 +- pylint/checkers/refactoring/__init__.py | 8 +- pylint/checkers/similar.py | 17 +--- pylint/checkers/spelling.py | 10 +-- pylint/checkers/strings.py | 3 +- pylint/checkers/typecheck.py | 35 +++----- pylint/checkers/unsupported_version.py | 7 +- pylint/checkers/variables.py | 14 +--- pylint/config/__init__.py | 14 ++-- pylint/config/_pylint_config/__init__.py | 3 +- pylint/config/_pylint_config/main.py | 3 +- pylint/config/arguments_manager.py | 30 +++---- pylint/config/configuration_mixin.py | 5 +- pylint/config/option_manager_mixin.py | 8 +- pylint/config/utils.py | 11 +-- pylint/extensions/dunder.py | 3 +- pylint/extensions/for_any_all.py | 7 +- pylint/extensions/no_self_use.py | 10 +-- pylint/extensions/redefined_variable_type.py | 3 +- pylint/extensions/typing.py | 11 +-- pylint/lint/__init__.py | 8 +- pylint/lint/base_options.py | 31 ++++--- pylint/lint/message_state_handler.py | 18 ++-- pylint/lint/pylinter.py | 36 +++----- pylint/lint/run.py | 9 +- pylint/message/message_id_store.py | 19 ++--- pylint/pyreverse/dot_printer.py | 3 +- pylint/pyreverse/main.py | 8 +- pylint/pyreverse/mermaidjs_printer.py | 3 +- pylint/pyreverse/plantuml_printer.py | 3 +- pylint/pyreverse/printer_factory.py | 3 +- pylint/pyreverse/vcg_printer.py | 3 +- pylint/pyreverse/writer.py | 13 ++- pylint/reporters/text.py | 3 +- pylint/reporters/ureports/base_writer.py | 9 +- pylint/reporters/ureports/text_writer.py | 12 +-- pylint/testutils/__init__.py | 3 +- pylint/testutils/_primer/__init__.py | 6 +- .../_primer/primer_compare_command.py | 8 +- .../testutils/_primer/primer_run_command.py | 8 +- pylint/testutils/functional/__init__.py | 14 ++-- pylint/testutils/functional_test_file.py | 7 +- pylint/testutils/lint_module_test.py | 5 +- pylint/typing.py | 15 +--- pylint/utils/__init__.py | 24 ++---- pylint/utils/file_state.py | 7 +- pylint/utils/utils.py | 13 +-- tests/checkers/unittest_misc.py | 3 +- tests/checkers/unittest_spelling.py | 3 +- .../config/test_find_default_config_files.py | 3 +- .../config/test_functional_config_loading.py | 7 +- tests/data/clientmodule_test.py | 3 +- tests/data/suppliermodule_test.py | 1 + .../a/abstract/abstract_abc_methods.py | 1 + .../a/abstract/abstract_class_instantiated.py | 1 + .../access_attr_before_def_false_positive.py | 1 + .../alternative_union_syntax_error.py | 1 - .../alternative_union_syntax_py37.py | 2 +- tests/functional/a/arguments.py | 2 + .../a/assigning/assigning_non_slot.py | 6 +- .../a/assigning/assigning_non_slot_4509.py | 1 + tests/functional/a/await_outside_async.py | 1 + tests/functional/b/bad_exception_cause.py | 4 +- tests/functional/b/bad_reversed_sequence.py | 2 +- .../functional/b/bad_thread_instantiation.py | 1 - tests/functional/b/builtin_module_test.py | 1 + tests/functional/c/class_members_py30.py | 3 + .../c/consider/consider_using_sys_exit.py | 1 + .../c/consider/consider_using_with.py | 2 +- .../d/dataclass_with_default_factory.py | 2 +- tests/functional/d/dataclass_with_field.py | 3 +- .../d/deprecated/deprecated_class_py33.py | 7 +- .../d/deprecated/deprecated_decorators.py | 1 + .../d/deprecated/deprecated_methods_py38.py | 1 + .../d/deprecated/deprecated_methods_py39.py | 1 + .../d/deprecated/deprecated_module_py3.py | 2 +- .../d/deprecated/deprecated_module_py36.py | 2 +- .../d/deprecated/deprecated_module_py4.py | 2 +- .../deprecated_module_uninstalled.py | 4 +- .../dot_relative_import.py | 3 +- .../subpackage/dot_dot_relative_import.py | 3 +- .../functional/d/disable_ungrouped_imports.py | 6 +- .../d/disable_wrong_import_order.py | 5 +- .../e/enum_self_defined_member_5138.py | 2 +- tests/functional/ext/check_elif/check_elif.py | 2 +- ..._consider_using_namedtuple_or_dataclass.py | 1 + .../ext/private_import/private_import.py | 84 ++++++++++--------- .../regression_newtype_fstring.py | 1 + .../ext/typing/typing_consider_using_alias.py | 2 +- ...ing_consider_using_alias_without_future.py | 2 +- .../ext/typing/typing_consider_using_union.py | 5 +- .../typing_consider_using_union_py310.py | 4 +- ...ing_consider_using_union_without_future.py | 4 +- .../ext/typing/typing_deprecated_alias.py | 2 +- .../functional/f/fallback_import_disabled.py | 4 +- tests/functional/f/fallback_import_enabled.py | 4 +- tests/functional/f/function_redefined.py | 6 ++ tests/functional/f/future_unicode_literals.py | 1 - tests/functional/g/generated_members.py | 3 + ...generic_alias_postponed_evaluation_py37.py | 1 - .../g/generic_alias/generic_alias_related.py | 2 +- .../generic_alias_related_py39.py | 2 +- .../generic_alias_side_effects.py | 3 +- tests/functional/i/import_aliasing.py | 35 ++++---- tests/functional/i/import_error.py | 29 +++---- tests/functional/i/import_outside_toplevel.py | 11 ++- .../i/inconsistent/inconsistent_returns.py | 1 + .../inconsistent_returns_noreturn.py | 2 + tests/functional/i/inference_crash_4692.py | 1 - .../i/invalid/invalid_bool_returned.py | 1 - .../i/invalid/invalid_bytes_returned.py | 1 - .../i/invalid/invalid_enum_extension.py | 1 + .../invalid_exceptions_caught.py | 8 +- .../i/invalid/invalid_format_returned.py | 1 - .../invalid_getnewargs_ex_returned.py | 1 - .../invalid_getnewargs_returned.py | 1 - .../i/invalid/invalid_hash_returned.py | 1 - .../i/invalid/invalid_index_returned.py | 1 - .../invalid_length_hint_returned.py | 1 - .../invalid_length/invalid_length_returned.py | 1 - tests/functional/i/invalid/invalid_name.py | 3 +- .../i/invalid/invalid_repr_returned.py | 1 - .../i/invalid/invalid_str_returned.py | 1 - .../i/isinstance_second_argument.py | 2 + tests/functional/i/iterable_context.py | 1 + tests/functional/i/iterable_context_py36.py | 1 + .../l/logging/logging_format_interpolation.py | 1 + .../logging_format_interpolation_py36.py | 1 - .../logging_fstring_interpolation_py36.py | 4 +- .../l/logging/logging_not_lazy_with_logger.py | 2 +- tests/functional/m/mapping_context.py | 1 + tests/functional/m/member/member_checks.py | 2 + .../functional/m/member/member_checks_py37.py | 2 +- tests/functional/m/membership_protocol.py | 1 + tests/functional/m/misplaced_future.py | 5 +- .../m/missing/missing_final_newline.py | 3 +- tests/functional/m/missing/missing_timeout.py | 34 ++++---- tests/functional/m/multiple_imports.py | 3 +- tests/functional/n/name/name_final.py | 1 + .../n/name/name_final_snake_case.py | 1 + .../n/namedtuple_member_inference.py | 1 - tests/functional/n/names_in__all__.py | 3 +- tests/functional/n/no/no_member.py | 1 + .../n/no/no_member_nested_namedtuple.py | 1 + .../n/no/no_member_subclassed_dataclasses.py | 3 +- tests/functional/n/no/no_name_in_module.py | 26 +++--- .../n/non/non_init_parent_called.py | 3 +- .../n/non_ascii_import/non_ascii_import.py | 5 +- .../non_ascii_import_as_bad.py | 1 - .../non_ascii_import_as_okay.py | 2 +- .../non_ascii_import_from_as.py | 1 - .../non_ascii_name_inline_var.py | 1 - tests/functional/n/not_context_manager.py | 3 + .../o/overridden_final_method_py38.py | 1 + .../p/postponed_evaluation_pep585.py | 5 +- .../p/postponed_evaluation_pep585_error.py | 1 - .../p/postponed_evaluation_pep585_py39.py | 4 +- .../r/raising/raising_non_exception.py | 1 + .../r/redefined/redefined_builtin.py | 5 +- .../redefined_outer_name_type_checking.py | 5 +- .../functional/r/redundant_unittest_assert.py | 1 + .../regression/regression_2306_enum_value.py | 1 + .../regression_3535_double_enum_inherit.py | 1 + ...regression_3595_notcallable_collections.py | 1 + .../regression_4221_object_instanceattr.py | 1 + .../regression_4358_unsubscriptable_enum.py | 1 + .../r/regression/regression_4891.py | 1 + .../r/regression_02/regression_4660.py | 2 +- .../r/regression_02/regression_5030.py | 4 +- .../r/regression_02/regression_5801.py | 1 + .../regression_distutil_import_error_73.py | 4 +- .../r/regression_02/regression_enum_1734.py | 1 + tests/functional/r/reimport.py | 3 +- tests/functional/r/reimported.py | 29 +++---- .../r/renamed_import_logging_not_lazy.py | 1 + tests/functional/s/shallow_copy_environ.py | 3 +- tests/functional/s/slots_checks.py | 1 + tests/functional/s/socketerror_import.py | 1 - .../s/stop_iteration_inside_generator.py | 2 + .../functional/s/string/string_formatting.py | 6 +- .../string_formatting_failed_inference.py | 1 + ...string_formatting_failed_inference_py35.py | 1 + .../s/string/string_formatting_py3.py | 2 +- .../s/subprocess_popen_preexec_fn.py | 1 + tests/functional/s/subprocess_run_check.py | 1 - tests/functional/s/super/super_checks.py | 1 + tests/functional/s/superfluous_parens.py | 1 + .../s/sys_stream_regression_1004.py | 1 + tests/functional/t/ternary.py | 3 +- .../t/too/too_few_public_methods_excluded.py | 1 + tests/functional/t/too/too_many_ancestors.py | 1 + .../too/too_many_instance_attributes_py37.py | 3 +- tests/functional/t/typing_use.py | 1 + .../u/unbalanced_tuple_unpacking.py | 2 + .../u/undefined/undefined_variable.py | 5 +- .../u/undefined/undefined_variable_py30.py | 1 + tests/functional/u/ungrouped_imports.py | 25 +++--- .../u/ungrouped_imports_suppression.py | 7 +- .../u/unnecessary/unnecessary_ellipsis.py | 2 +- .../u/unpacking/unpacking_non_sequence.py | 2 +- tests/functional/u/unreachable.py | 1 + tests/functional/u/unsubscriptable_value.py | 2 + .../unsupported_assignment_operation.py | 2 + .../unsupported_binary_operation.py | 3 +- .../unsupported_delete_operation.py | 2 + tests/functional/u/unused/unused_import.py | 18 ++-- .../unused/unused_import_class_def_keyword.py | 4 +- .../functional/u/unused/unused_import_py30.py | 5 +- .../functional/u/unused/unused_import_py39.py | 3 +- .../unused_name_from_wildcard_import.py | 4 +- ..._name_in_string_literal_type_annotation.py | 2 +- ...in_string_literal_type_annotation_py310.py | 1 + ..._in_string_literal_type_annotation_py38.py | 6 +- ..._in_string_literal_type_annotation_py39.py | 1 + .../u/unused/unused_typing_imports.py | 14 +--- tests/functional/u/unused/unused_variable.py | 19 +++-- .../unused/unused_variable_after_inference.py | 2 + .../use_implicit_booleaness_not_comparison.py | 4 +- .../u/used/used_before_assignment.py | 2 + .../used_before_assignment_else_return.py | 1 + .../u/used/used_before_assignment_py37.py | 1 + ...used_before_assignment_type_annotations.py | 1 + .../u/used/used_before_assignment_typing.py | 2 +- .../u/useless/useless_object_inheritance.py | 1 + .../u/useless/useless_suppression.py | 3 +- .../functional/u/useless/useless_with_lock.py | 3 +- tests/functional/w/wildcard_import.py | 4 +- tests/functional/w/wildcard_import_allowed.py | 3 +- tests/functional/w/wrong_import_order.py | 28 ++++--- tests/functional/w/wrong_import_order2.py | 1 - tests/functional/w/wrong_import_position.py | 2 +- tests/functional/w/wrong_import_position9.py | 1 + ...ong_import_position_exclude_dunder_main.py | 3 +- tests/input/func_3k_removed_stuff_py_30.py | 2 + .../func_w0401_package/all_the_things.py | 4 +- tests/input/func_w0401_package/thing2.py | 1 + tests/lint/unittest_lint.py | 14 +--- tests/message/conftest.py | 3 +- tests/pyreverse/test_diadefs.py | 9 +- tests/pyreverse/test_pyreverse_functional.py | 6 +- tests/pyreverse/test_utils.py | 8 +- tests/regrtest_data/absimp/string.py | 2 + tests/regrtest_data/bad_package/__init__.py | 3 +- tests/regrtest_data/beyond_top/__init__.py | 1 + tests/regrtest_data/decimal_inference.py | 1 + tests/regrtest_data/descriptor_crash.py | 1 + tests/regrtest_data/dummy/__init__.py | 2 +- tests/regrtest_data/fail_on.py | 1 + tests/regrtest_data/fail_under_plus7_5.py | 1 + tests/regrtest_data/func_block_disable_msg.py | 1 + .../hang/pkg4972/string/__init__.py | 2 + tests/regrtest_data/import_assign.py | 3 +- .../import_package_subpackage_module.py | 1 + .../imported_module_in_typehint/module_a.py | 1 - tests/regrtest_data/numarray_inf.py | 1 + tests/regrtest_data/precedence_test.py | 2 + tests/test_check_parallel.py | 3 +- tests/test_deprecation.py | 10 +-- tests/test_func.py | 3 +- tests/test_functional.py | 6 +- tests/test_functional_directories.py | 5 +- tests/test_pragma_parser.py | 8 +- tests/test_self.py | 8 +- tests/testutils/test_functional_testutils.py | 4 +- tests/testutils/test_testutils_utils.py | 3 +- 276 files changed, 683 insertions(+), 803 deletions(-) diff --git a/pylint/checkers/__init__.py b/pylint/checkers/__init__.py index ed641d8e5bc..2696b582fa5 100644 --- a/pylint/checkers/__init__.py +++ b/pylint/checkers/__init__.py @@ -45,11 +45,8 @@ import sys from typing import TYPE_CHECKING -from pylint.checkers.base_checker import ( - BaseChecker, - BaseRawFileChecker, - BaseTokenChecker, -) +from pylint.checkers.base_checker import (BaseChecker, BaseRawFileChecker, + BaseTokenChecker) from pylint.checkers.deprecated import DeprecatedMixin from pylint.checkers.mapreduce_checker import MapReduceMixin from pylint.utils import LinterStats, diff_string, register_plugins diff --git a/pylint/checkers/base/__init__.py b/pylint/checkers/base/__init__.py index f427cbf21b6..4c04dc13ba0 100644 --- a/pylint/checkers/base/__init__.py +++ b/pylint/checkers/base/__init__.py @@ -23,15 +23,10 @@ from pylint.checkers.base.basic_error_checker import BasicErrorChecker from pylint.checkers.base.comparison_checker import ComparisonChecker from pylint.checkers.base.docstring_checker import DocStringChecker -from pylint.checkers.base.name_checker import ( - KNOWN_NAME_TYPES_WITH_STYLE, - AnyStyle, - CamelCaseStyle, - NamingStyle, - PascalCaseStyle, - SnakeCaseStyle, - UpperCaseStyle, -) +from pylint.checkers.base.name_checker import (KNOWN_NAME_TYPES_WITH_STYLE, + AnyStyle, CamelCaseStyle, + NamingStyle, PascalCaseStyle, + SnakeCaseStyle, UpperCaseStyle) from pylint.checkers.base.name_checker.checker import NameChecker from pylint.checkers.base.pass_checker import PassChecker diff --git a/pylint/checkers/base/docstring_checker.py b/pylint/checkers/base/docstring_checker.py index 791b085b5cb..7373311a0fc 100644 --- a/pylint/checkers/base/docstring_checker.py +++ b/pylint/checkers/base/docstring_checker.py @@ -15,11 +15,8 @@ from pylint import interfaces from pylint.checkers import utils from pylint.checkers.base.basic_checker import _BasicChecker -from pylint.checkers.utils import ( - is_overload_stub, - is_property_deleter, - is_property_setter, -) +from pylint.checkers.utils import (is_overload_stub, is_property_deleter, + is_property_setter) if sys.version_info >= (3, 8): from typing import Literal diff --git a/pylint/checkers/base/name_checker/__init__.py b/pylint/checkers/base/name_checker/__init__.py index 3d6818b7ab5..e50c240a363 100644 --- a/pylint/checkers/base/name_checker/__init__.py +++ b/pylint/checkers/base/name_checker/__init__.py @@ -15,11 +15,5 @@ from pylint.checkers.base.name_checker.checker import NameChecker from pylint.checkers.base.name_checker.naming_style import ( - KNOWN_NAME_TYPES_WITH_STYLE, - AnyStyle, - CamelCaseStyle, - NamingStyle, - PascalCaseStyle, - SnakeCaseStyle, - UpperCaseStyle, -) + KNOWN_NAME_TYPES_WITH_STYLE, AnyStyle, CamelCaseStyle, NamingStyle, + PascalCaseStyle, SnakeCaseStyle, UpperCaseStyle) diff --git a/pylint/checkers/base/name_checker/checker.py b/pylint/checkers/base/name_checker/checker.py index 0eded5f9ba7..6f9962f46c5 100644 --- a/pylint/checkers/base/name_checker/checker.py +++ b/pylint/checkers/base/name_checker/checker.py @@ -23,11 +23,8 @@ from pylint.checkers import utils from pylint.checkers.base.basic_checker import _BasicChecker from pylint.checkers.base.name_checker.naming_style import ( - KNOWN_NAME_TYPES, - KNOWN_NAME_TYPES_WITH_STYLE, - NAMING_STYLES, - _create_naming_options, -) + KNOWN_NAME_TYPES, KNOWN_NAME_TYPES_WITH_STYLE, NAMING_STYLES, + _create_naming_options) from pylint.checkers.utils import is_property_deleter, is_property_setter from pylint.typing import Options diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py index 0debfd3a2ae..d7b7a147463 100644 --- a/pylint/checkers/base_checker.py +++ b/pylint/checkers/base_checker.py @@ -17,15 +17,11 @@ from pylint.config.arguments_provider import _ArgumentsProvider from pylint.constants import _MSG_ORDER, MAIN_CHECKER_NAME, WarningScope from pylint.exceptions import InvalidMessageError -from pylint.interfaces import Confidence, IRawChecker, ITokenChecker, implements +from pylint.interfaces import (Confidence, IRawChecker, ITokenChecker, + implements) from pylint.message.message_definition import MessageDefinition -from pylint.typing import ( - ExtraMessageOptions, - MessageDefinitionTuple, - OptionDict, - Options, - ReportsCallable, -) +from pylint.typing import (ExtraMessageOptions, MessageDefinitionTuple, + OptionDict, Options, ReportsCallable) from pylint.utils import get_rst_section, get_rst_title if TYPE_CHECKING: diff --git a/pylint/checkers/classes/__init__.py b/pylint/checkers/classes/__init__.py index e5119443901..4e84227a1e5 100644 --- a/pylint/checkers/classes/__init__.py +++ b/pylint/checkers/classes/__init__.py @@ -7,7 +7,8 @@ from typing import TYPE_CHECKING from pylint.checkers.classes.class_checker import ClassChecker -from pylint.checkers.classes.special_methods_checker import SpecialMethodsChecker +from pylint.checkers.classes.special_methods_checker import \ + SpecialMethodsChecker if TYPE_CHECKING: from pylint.lint import PyLinter diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index e2806ef4331..1f1ddecc9ee 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -20,26 +20,17 @@ from astroid.typing import SuccessfulInferenceResult from pylint.checkers import BaseChecker, utils -from pylint.checkers.utils import ( - PYMETHODS, - class_is_abstract, - decorated_with, - decorated_with_property, - get_outer_class, - has_known_bases, - is_attr_private, - is_attr_protected, - is_builtin_object, - is_comprehension, - is_iterable, - is_property_setter, - is_property_setter_or_deleter, - node_frame_class, - only_required_for_messages, - safe_infer, - unimplemented_abstract_methods, - uninferable_final_decorators, -) +from pylint.checkers.utils import (PYMETHODS, class_is_abstract, + decorated_with, decorated_with_property, + get_outer_class, has_known_bases, + is_attr_private, is_attr_protected, + is_builtin_object, is_comprehension, + is_iterable, is_property_setter, + is_property_setter_or_deleter, + node_frame_class, + only_required_for_messages, safe_infer, + unimplemented_abstract_methods, + uninferable_final_decorators) from pylint.interfaces import HIGH, INFERENCE from pylint.typing import MessageDefinitionTuple diff --git a/pylint/checkers/classes/special_methods_checker.py b/pylint/checkers/classes/special_methods_checker.py index 6d95615b143..e42df41023d 100644 --- a/pylint/checkers/classes/special_methods_checker.py +++ b/pylint/checkers/classes/special_methods_checker.py @@ -14,14 +14,9 @@ from astroid.typing import InferenceResult from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - PYMETHODS, - SPECIAL_METHODS_PARAMS, - decorated_with, - is_function_body_ellipsis, - only_required_for_messages, - safe_infer, -) +from pylint.checkers.utils import (PYMETHODS, SPECIAL_METHODS_PARAMS, + decorated_with, is_function_body_ellipsis, + only_required_for_messages, safe_infer) from pylint.lint.pylinter import PyLinter NEXT_METHOD = "__next__" diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index cde34b5d7e3..dc86c633673 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -22,16 +22,14 @@ from astroid import nodes from pylint.checkers import BaseRawFileChecker, BaseTokenChecker -from pylint.checkers.utils import ( - is_overload_stub, - is_protocol_class, - node_frame_class, - only_required_for_messages, -) +from pylint.checkers.utils import (is_overload_stub, is_protocol_class, + node_frame_class, + only_required_for_messages) from pylint.constants import WarningScope from pylint.interfaces import HIGH from pylint.typing import MessageDefinitionTuple -from pylint.utils.pragma_parser import OPTION_PO, PragmaParserError, parse_pragma +from pylint.utils.pragma_parser import (OPTION_PO, PragmaParserError, + parse_pragma) if TYPE_CHECKING: from pylint.lint import PyLinter diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 61c18649ba7..2c0362b6a21 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -19,13 +19,9 @@ from astroid.nodes._base_nodes import ImportNode from pylint.checkers import BaseChecker, DeprecatedMixin -from pylint.checkers.utils import ( - get_import_name, - is_from_fallback_block, - is_node_in_guarded_import_block, - is_typing_guard, - node_ignores_exception, -) +from pylint.checkers.utils import (get_import_name, is_from_fallback_block, + is_node_in_guarded_import_block, + is_typing_guard, node_ignores_exception) from pylint.exceptions import EmptyReportError from pylint.graph import DotBackend, get_cycles from pylint.interfaces import HIGH diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py index 0aed9718365..96ab9870742 100644 --- a/pylint/checkers/newstyle.py +++ b/pylint/checkers/newstyle.py @@ -12,11 +12,8 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - has_known_bases, - node_frame_class, - only_required_for_messages, -) +from pylint.checkers.utils import (has_known_bases, node_frame_class, + only_required_for_messages) from pylint.typing import MessageDefinitionTuple if TYPE_CHECKING: diff --git a/pylint/checkers/refactoring/__init__.py b/pylint/checkers/refactoring/__init__.py index d215dcee27a..437ad344675 100644 --- a/pylint/checkers/refactoring/__init__.py +++ b/pylint/checkers/refactoring/__init__.py @@ -8,11 +8,11 @@ from typing import TYPE_CHECKING -from pylint.checkers.refactoring.implicit_booleaness_checker import ( - ImplicitBooleanessChecker, -) +from pylint.checkers.refactoring.implicit_booleaness_checker import \ + ImplicitBooleanessChecker from pylint.checkers.refactoring.not_checker import NotChecker -from pylint.checkers.refactoring.recommendation_checker import RecommendationChecker +from pylint.checkers.refactoring.recommendation_checker import \ + RecommendationChecker from pylint.checkers.refactoring.refactoring_checker import RefactoringChecker if TYPE_CHECKING: diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 3b18ddbfdfa..5d6803be104 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -32,23 +32,14 @@ from getopt import getopt from io import BufferedIOBase, BufferedReader, BytesIO from itertools import chain, groupby -from typing import ( - TYPE_CHECKING, - Any, - Dict, - List, - NamedTuple, - NewType, - NoReturn, - TextIO, - Tuple, - Union, -) +from typing import (TYPE_CHECKING, Any, Dict, List, NamedTuple, NewType, + NoReturn, TextIO, Tuple, Union) import astroid from astroid import nodes -from pylint.checkers import BaseChecker, BaseRawFileChecker, table_lines_from_stats +from pylint.checkers import (BaseChecker, BaseRawFileChecker, + table_lines_from_stats) from pylint.reporters.ureports.nodes import Section, Table from pylint.typing import MessageDefinitionTuple, Options from pylint.utils import LinterStats, decoding_stream diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index 23209a2bc45..f0694b2eb7f 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -27,14 +27,8 @@ try: import enchant - from enchant.tokenize import ( - Chunker, - EmailFilter, - Filter, - URLFilter, - WikiWordFilter, - get_tokenizer, - ) + from enchant.tokenize import (Chunker, EmailFilter, Filter, URLFilter, + WikiWordFilter, get_tokenizer) except ImportError: enchant = None diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index 4afe32a169b..7071a99725b 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -18,7 +18,8 @@ from astroid import bases, nodes from astroid.typing import SuccessfulInferenceResult -from pylint.checkers import BaseChecker, BaseRawFileChecker, BaseTokenChecker, utils +from pylint.checkers import (BaseChecker, BaseRawFileChecker, BaseTokenChecker, + utils) from pylint.checkers.utils import only_required_for_messages from pylint.interfaces import HIGH from pylint.typing import MessageDefinitionTuple diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 192bccbbba4..1b75ec70215 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -25,29 +25,18 @@ from astroid.typing import InferenceResult, SuccessfulInferenceResult from pylint.checkers import BaseChecker, utils -from pylint.checkers.utils import ( - decorated_with, - decorated_with_property, - has_known_bases, - is_builtin_object, - is_comprehension, - is_hashable, - is_inside_abstract_class, - is_iterable, - is_mapping, - is_module_ignored, - is_node_in_type_annotation_context, - is_overload_stub, - is_postponed_evaluation_enabled, - is_super, - node_ignores_exception, - only_required_for_messages, - safe_infer, - supports_delitem, - supports_getitem, - supports_membership_test, - supports_setitem, -) +from pylint.checkers.utils import (decorated_with, decorated_with_property, + has_known_bases, is_builtin_object, + is_comprehension, is_hashable, + is_inside_abstract_class, is_iterable, + is_mapping, is_module_ignored, + is_node_in_type_annotation_context, + is_overload_stub, + is_postponed_evaluation_enabled, is_super, + node_ignores_exception, + only_required_for_messages, safe_infer, + supports_delitem, supports_getitem, + supports_membership_test, supports_setitem) from pylint.interfaces import HIGH, INFERENCE from pylint.typing import MessageDefinitionTuple diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py index 0c4a7c5bbe9..b8f880b13e7 100644 --- a/pylint/checkers/unsupported_version.py +++ b/pylint/checkers/unsupported_version.py @@ -13,11 +13,8 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - only_required_for_messages, - safe_infer, - uninferable_final_decorators, -) +from pylint.checkers.utils import (only_required_for_messages, safe_infer, + uninferable_final_decorators) if TYPE_CHECKING: from pylint.lint import PyLinter diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 32843417ca7..96d9daec4fa 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -24,16 +24,10 @@ from astroid.typing import InferenceResult from pylint.checkers import BaseChecker, utils -from pylint.checkers.utils import ( - in_type_checking_block, - is_postponed_evaluation_enabled, -) -from pylint.constants import ( - PY39_PLUS, - TYPING_NEVER, - TYPING_NORETURN, - TYPING_TYPE_CHECKS_GUARDS, -) +from pylint.checkers.utils import (in_type_checking_block, + is_postponed_evaluation_enabled) +from pylint.constants import (PY39_PLUS, TYPING_NEVER, TYPING_NORETURN, + TYPING_TYPE_CHECKS_GUARDS) from pylint.interfaces import CONTROL_FLOW, HIGH, INFERENCE, INFERENCE_FAILURE from pylint.typing import MessageDefinitionTuple diff --git a/pylint/config/__init__.py b/pylint/config/__init__.py index 5f90bbae02e..012c5d5889f 100644 --- a/pylint/config/__init__.py +++ b/pylint/config/__init__.py @@ -25,16 +25,14 @@ from pylint.config.arguments_provider import UnsupportedAction from pylint.config.configuration_mixin import ConfigurationMixIn from pylint.config.environment_variable import PYLINTRC -from pylint.config.find_default_config_files import ( - find_default_config_files, - find_pylintrc, -) +from pylint.config.find_default_config_files import (find_default_config_files, + find_pylintrc) from pylint.config.option import Option from pylint.config.option_manager_mixin import OptionsManagerMixIn -from pylint.config.option_parser import OptionParser # type: ignore[attr-defined] -from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined] - OptionsProviderMixIn, -) +from pylint.config.option_parser import \ + OptionParser # type: ignore[attr-defined] +from pylint.config.options_provider_mixin import \ + OptionsProviderMixIn # type: ignore[attr-defined] from pylint.constants import PYLINT_HOME, USER_HOME from pylint.utils import LinterStats diff --git a/pylint/config/_pylint_config/__init__.py b/pylint/config/_pylint_config/__init__.py index 622d0dfe36a..70f60fbb702 100644 --- a/pylint/config/_pylint_config/__init__.py +++ b/pylint/config/_pylint_config/__init__.py @@ -8,6 +8,7 @@ """ from pylint.config._pylint_config.main import _handle_pylint_config_commands -from pylint.config._pylint_config.setup import _register_generate_config_options +from pylint.config._pylint_config.setup import \ + _register_generate_config_options __all__ = ("_handle_pylint_config_commands", "_register_generate_config_options") diff --git a/pylint/config/_pylint_config/main.py b/pylint/config/_pylint_config/main.py index 716702df5ee..12d51877939 100644 --- a/pylint/config/_pylint_config/main.py +++ b/pylint/config/_pylint_config/main.py @@ -9,7 +9,8 @@ from typing import TYPE_CHECKING -from pylint.config._pylint_config.generate_command import handle_generate_command +from pylint.config._pylint_config.generate_command import \ + handle_generate_command from pylint.config._pylint_config.help_message import get_help if TYPE_CHECKING: diff --git a/pylint/config/arguments_manager.py b/pylint/config/arguments_manager.py index c771ad35506..784844f93bb 100644 --- a/pylint/config/arguments_manager.py +++ b/pylint/config/arguments_manager.py @@ -23,26 +23,20 @@ import tomlkit from pylint import utils -from pylint.config.argument import ( - _Argument, - _CallableArgument, - _ExtendArgument, - _StoreArgument, - _StoreNewNamesArgument, - _StoreOldNamesArgument, - _StoreTrueArgument, -) -from pylint.config.exceptions import ( - UnrecognizedArgumentAction, - _UnrecognizedOptionError, -) +from pylint.config.argument import (_Argument, _CallableArgument, + _ExtendArgument, _StoreArgument, + _StoreNewNamesArgument, + _StoreOldNamesArgument, _StoreTrueArgument) +from pylint.config.exceptions import (UnrecognizedArgumentAction, + _UnrecognizedOptionError) from pylint.config.help_formatter import _HelpFormatter from pylint.config.option import Option -from pylint.config.option_parser import OptionParser # type: ignore[attr-defined] -from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined] - OptionsProviderMixIn, -) -from pylint.config.utils import _convert_option_to_argument, _parse_rich_type_value +from pylint.config.option_parser import \ + OptionParser # type: ignore[attr-defined] +from pylint.config.options_provider_mixin import \ + OptionsProviderMixIn # type: ignore[attr-defined] +from pylint.config.utils import (_convert_option_to_argument, + _parse_rich_type_value) from pylint.constants import MAIN_CHECKER_NAME from pylint.typing import DirectoryNamespaceDict, OptionDict diff --git a/pylint/config/configuration_mixin.py b/pylint/config/configuration_mixin.py index 55857224ac4..8fceb522588 100644 --- a/pylint/config/configuration_mixin.py +++ b/pylint/config/configuration_mixin.py @@ -8,9 +8,8 @@ from typing import Any from pylint.config.option_manager_mixin import OptionsManagerMixIn -from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined] - OptionsProviderMixIn, -) +from pylint.config.options_provider_mixin import \ + OptionsProviderMixIn # type: ignore[attr-defined] class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn): # type: ignore[misc] diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py index c468f494fcc..d10c03fe940 100644 --- a/pylint/config/option_manager_mixin.py +++ b/pylint/config/option_manager_mixin.py @@ -21,13 +21,13 @@ from pylint import utils from pylint.config.option import Option -from pylint.config.option_parser import OptionParser # type: ignore[attr-defined] +from pylint.config.option_parser import \ + OptionParser # type: ignore[attr-defined] from pylint.typing import OptionDict if TYPE_CHECKING: - from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined] - OptionsProviderMixin, - ) + from pylint.config.options_provider_mixin import \ + OptionsProviderMixin # type: ignore[attr-defined] if sys.version_info >= (3, 11): import tomllib diff --git a/pylint/config/utils.py b/pylint/config/utils.py index d7cbd7c0750..336a9292c25 100644 --- a/pylint/config/utils.py +++ b/pylint/config/utils.py @@ -13,14 +13,9 @@ from typing import TYPE_CHECKING, Any from pylint import extensions, utils -from pylint.config.argument import ( - _CallableArgument, - _ExtendArgument, - _StoreArgument, - _StoreNewNamesArgument, - _StoreOldNamesArgument, - _StoreTrueArgument, -) +from pylint.config.argument import (_CallableArgument, _ExtendArgument, + _StoreArgument, _StoreNewNamesArgument, + _StoreOldNamesArgument, _StoreTrueArgument) from pylint.config.callback_actions import _CallbackAction from pylint.config.exceptions import ArgumentPreprocessingError diff --git a/pylint/extensions/dunder.py b/pylint/extensions/dunder.py index e0e9af316ac..20a3a2d1011 100644 --- a/pylint/extensions/dunder.py +++ b/pylint/extensions/dunder.py @@ -9,7 +9,8 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.constants import DUNDER_METHODS, DUNDER_PROPERTIES, EXTRA_DUNDER_METHODS +from pylint.constants import (DUNDER_METHODS, DUNDER_PROPERTIES, + EXTRA_DUNDER_METHODS) from pylint.interfaces import HIGH if TYPE_CHECKING: diff --git a/pylint/extensions/for_any_all.py b/pylint/extensions/for_any_all.py index 257b5d37f8e..9d9fda9847b 100644 --- a/pylint/extensions/for_any_all.py +++ b/pylint/extensions/for_any_all.py @@ -11,11 +11,8 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - assigned_bool, - only_required_for_messages, - returns_bool, -) +from pylint.checkers.utils import (assigned_bool, only_required_for_messages, + returns_bool) from pylint.interfaces import HIGH if TYPE_CHECKING: diff --git a/pylint/extensions/no_self_use.py b/pylint/extensions/no_self_use.py index 4a20873c842..20111053f05 100644 --- a/pylint/extensions/no_self_use.py +++ b/pylint/extensions/no_self_use.py @@ -9,13 +9,9 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - PYMETHODS, - decorated_with_property, - is_overload_stub, - is_protocol_class, - overrides_a_method, -) +from pylint.checkers.utils import (PYMETHODS, decorated_with_property, + is_overload_stub, is_protocol_class, + overrides_a_method) from pylint.interfaces import INFERENCE if TYPE_CHECKING: diff --git a/pylint/extensions/redefined_variable_type.py b/pylint/extensions/redefined_variable_type.py index ae7344cc1b0..cdf4dfe2af2 100644 --- a/pylint/extensions/redefined_variable_type.py +++ b/pylint/extensions/redefined_variable_type.py @@ -9,7 +9,8 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import is_none, node_type, only_required_for_messages +from pylint.checkers.utils import (is_none, node_type, + only_required_for_messages) if TYPE_CHECKING: from pylint.lint import PyLinter diff --git a/pylint/extensions/typing.py b/pylint/extensions/typing.py index 5f89cd5613f..4eb88281e96 100644 --- a/pylint/extensions/typing.py +++ b/pylint/extensions/typing.py @@ -10,13 +10,10 @@ from astroid import nodes from pylint.checkers import BaseChecker -from pylint.checkers.utils import ( - in_type_checking_block, - is_node_in_type_annotation_context, - is_postponed_evaluation_enabled, - only_required_for_messages, - safe_infer, -) +from pylint.checkers.utils import (in_type_checking_block, + is_node_in_type_annotation_context, + is_postponed_evaluation_enabled, + only_required_for_messages, safe_infer) from pylint.constants import TYPING_NORETURN from pylint.interfaces import INFERENCE diff --git a/pylint/lint/__init__.py b/pylint/lint/__init__.py index 86186ebd408..d716285ba72 100644 --- a/pylint/lint/__init__.py +++ b/pylint/lint/__init__.py @@ -20,11 +20,9 @@ from pylint.lint.caching import load_results, save_results from pylint.lint.parallel import check_parallel from pylint.lint.pylinter import PyLinter -from pylint.lint.report_functions import ( - report_messages_by_module_stats, - report_messages_stats, - report_total_messages_stats, -) +from pylint.lint.report_functions import (report_messages_by_module_stats, + report_messages_stats, + report_total_messages_stats) from pylint.lint.run import Run from pylint.lint.utils import _patch_sys_path, fix_import_path diff --git a/pylint/lint/base_options.py b/pylint/lint/base_options.py index 6de88e44e4d..13a487e81e9 100644 --- a/pylint/lint/base_options.py +++ b/pylint/lint/base_options.py @@ -11,23 +11,20 @@ from typing import TYPE_CHECKING from pylint import constants, interfaces -from pylint.config.callback_actions import ( - _DisableAction, - _DoNothingAction, - _EnableAction, - _ErrorsOnlyModeAction, - _FullDocumentationAction, - _GenerateConfigFileAction, - _GenerateRCFileAction, - _ListCheckGroupsAction, - _ListConfidenceLevelsAction, - _ListExtensionsAction, - _ListMessagesAction, - _ListMessagesEnabledAction, - _LongHelpAction, - _MessageHelpAction, - _OutputFormatAction, -) +from pylint.config.callback_actions import (_DisableAction, _DoNothingAction, + _EnableAction, + _ErrorsOnlyModeAction, + _FullDocumentationAction, + _GenerateConfigFileAction, + _GenerateRCFileAction, + _ListCheckGroupsAction, + _ListConfidenceLevelsAction, + _ListExtensionsAction, + _ListMessagesAction, + _ListMessagesEnabledAction, + _LongHelpAction, + _MessageHelpAction, + _OutputFormatAction) from pylint.typing import Options if TYPE_CHECKING: diff --git a/pylint/lint/message_state_handler.py b/pylint/lint/message_state_handler.py index 7c81c2c8623..5f5785400af 100644 --- a/pylint/lint/message_state_handler.py +++ b/pylint/lint/message_state_handler.py @@ -10,22 +10,14 @@ from typing import TYPE_CHECKING from pylint import exceptions, interfaces -from pylint.constants import ( - MSG_STATE_CONFIDENCE, - MSG_STATE_SCOPE_CONFIG, - MSG_STATE_SCOPE_MODULE, - MSG_TYPES, - MSG_TYPES_LONG, -) +from pylint.constants import (MSG_STATE_CONFIDENCE, MSG_STATE_SCOPE_CONFIG, + MSG_STATE_SCOPE_MODULE, MSG_TYPES, + MSG_TYPES_LONG) from pylint.interfaces import HIGH from pylint.message import MessageDefinition from pylint.typing import ManagedMessage -from pylint.utils.pragma_parser import ( - OPTION_PO, - InvalidPragmaError, - UnRecognizedOptionError, - parse_pragma, -) +from pylint.utils.pragma_parser import (OPTION_PO, InvalidPragmaError, + UnRecognizedOptionError, parse_pragma) if sys.version_info >= (3, 8): from typing import Literal diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 70f27c7c027..a74f39ae88c 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -27,42 +27,26 @@ from pylint import checkers, exceptions, interfaces, reporters from pylint.checkers.base_checker import BaseChecker from pylint.config.arguments_manager import _ArgumentsManager -from pylint.constants import ( - MAIN_CHECKER_NAME, - MSG_TYPES, - MSG_TYPES_STATUS, - WarningScope, -) +from pylint.constants import (MAIN_CHECKER_NAME, MSG_TYPES, MSG_TYPES_STATUS, + WarningScope) from pylint.interfaces import HIGH from pylint.lint.base_options import _make_linter_options from pylint.lint.caching import load_results, save_results from pylint.lint.expand_modules import _is_ignored_file, expand_modules from pylint.lint.message_state_handler import _MessageStateHandler from pylint.lint.parallel import check_parallel -from pylint.lint.report_functions import ( - report_messages_by_module_stats, - report_messages_stats, - report_total_messages_stats, -) -from pylint.lint.utils import ( - _is_relative_to, - fix_import_path, - get_fatal_error_message, - prepare_crash_report, -) +from pylint.lint.report_functions import (report_messages_by_module_stats, + report_messages_stats, + report_total_messages_stats) +from pylint.lint.utils import (_is_relative_to, fix_import_path, + get_fatal_error_message, prepare_crash_report) from pylint.message import Message, MessageDefinition, MessageDefinitionStore from pylint.reporters.base_reporter import BaseReporter from pylint.reporters.text import TextReporter from pylint.reporters.ureports import nodes as report_nodes -from pylint.typing import ( - DirectoryNamespaceDict, - FileItem, - ManagedMessage, - MessageDefinitionTuple, - MessageLocationTuple, - ModuleDescriptionDict, - Options, -) +from pylint.typing import (DirectoryNamespaceDict, FileItem, ManagedMessage, + MessageDefinitionTuple, MessageLocationTuple, + ModuleDescriptionDict, Options) from pylint.utils import ASTWalker, FileState, LinterStats, utils if sys.version_info >= (3, 8): diff --git a/pylint/lint/run.py b/pylint/lint/run.py index b8923aac5f4..e8a6885957f 100644 --- a/pylint/lint/run.py +++ b/pylint/lint/run.py @@ -12,10 +12,8 @@ from typing import Any, ClassVar from pylint import config -from pylint.config._pylint_config import ( - _handle_pylint_config_commands, - _register_generate_config_options, -) +from pylint.config._pylint_config import (_handle_pylint_config_commands, + _register_generate_config_options) from pylint.config.config_initialization import _config_initialization from pylint.config.exceptions import ArgumentPreprocessingError from pylint.config.utils import _preprocess_options @@ -26,7 +24,8 @@ try: import multiprocessing - from multiprocessing import synchronize # noqa pylint: disable=unused-import + from multiprocessing import \ + synchronize # noqa pylint: disable=unused-import except ImportError: multiprocessing = None # type: ignore[assignment] diff --git a/pylint/message/message_id_store.py b/pylint/message/message_id_store.py index d1810bd2bd3..c4758160352 100644 --- a/pylint/message/message_id_store.py +++ b/pylint/message/message_id_store.py @@ -6,18 +6,13 @@ from typing import NoReturn -from pylint.exceptions import ( - DeletedMessageError, - InvalidMessageError, - MessageBecameExtensionError, - UnknownMessageError, -) -from pylint.message._deleted_message_ids import ( - is_deleted_msgid, - is_deleted_symbol, - is_moved_msgid, - is_moved_symbol, -) +from pylint.exceptions import (DeletedMessageError, InvalidMessageError, + MessageBecameExtensionError, + UnknownMessageError) +from pylint.message._deleted_message_ids import (is_deleted_msgid, + is_deleted_symbol, + is_moved_msgid, + is_moved_symbol) class MessageIdStore: diff --git a/pylint/pyreverse/dot_printer.py b/pylint/pyreverse/dot_printer.py index 7579d2877e2..e63a52e3dff 100644 --- a/pylint/pyreverse/dot_printer.py +++ b/pylint/pyreverse/dot_printer.py @@ -15,7 +15,8 @@ from astroid import nodes -from pylint.pyreverse.printer import EdgeType, Layout, NodeProperties, NodeType, Printer +from pylint.pyreverse.printer import (EdgeType, Layout, NodeProperties, + NodeType, Printer) from pylint.pyreverse.utils import get_annotation_label diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 72429b41a27..9cf57ca44c0 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -17,11 +17,9 @@ from pylint.pyreverse import writer from pylint.pyreverse.diadefslib import DiadefsHandler from pylint.pyreverse.inspector import Linker, project_from_files -from pylint.pyreverse.utils import ( - check_graphviz_availability, - check_if_graphviz_supports_format, - insert_default_options, -) +from pylint.pyreverse.utils import (check_graphviz_availability, + check_if_graphviz_supports_format, + insert_default_options) from pylint.typing import Options DIRECTLY_SUPPORTED_FORMATS = ( diff --git a/pylint/pyreverse/mermaidjs_printer.py b/pylint/pyreverse/mermaidjs_printer.py index 07cad97bed4..57cd7a93525 100644 --- a/pylint/pyreverse/mermaidjs_printer.py +++ b/pylint/pyreverse/mermaidjs_printer.py @@ -6,7 +6,8 @@ from __future__ import annotations -from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType, Printer +from pylint.pyreverse.printer import (EdgeType, NodeProperties, NodeType, + Printer) from pylint.pyreverse.utils import get_annotation_label diff --git a/pylint/pyreverse/plantuml_printer.py b/pylint/pyreverse/plantuml_printer.py index f3f639f5ce8..4a5ef38100f 100644 --- a/pylint/pyreverse/plantuml_printer.py +++ b/pylint/pyreverse/plantuml_printer.py @@ -6,7 +6,8 @@ from __future__ import annotations -from pylint.pyreverse.printer import EdgeType, Layout, NodeProperties, NodeType, Printer +from pylint.pyreverse.printer import (EdgeType, Layout, NodeProperties, + NodeType, Printer) from pylint.pyreverse.utils import get_annotation_label diff --git a/pylint/pyreverse/printer_factory.py b/pylint/pyreverse/printer_factory.py index 41e8b46c88a..97e7a0d1aec 100644 --- a/pylint/pyreverse/printer_factory.py +++ b/pylint/pyreverse/printer_factory.py @@ -5,7 +5,8 @@ from __future__ import annotations from pylint.pyreverse.dot_printer import DotPrinter -from pylint.pyreverse.mermaidjs_printer import HTMLMermaidJSPrinter, MermaidJSPrinter +from pylint.pyreverse.mermaidjs_printer import (HTMLMermaidJSPrinter, + MermaidJSPrinter) from pylint.pyreverse.plantuml_printer import PlantUmlPrinter from pylint.pyreverse.printer import Printer from pylint.pyreverse.vcg_printer import VCGPrinter diff --git a/pylint/pyreverse/vcg_printer.py b/pylint/pyreverse/vcg_printer.py index 6f28a24e87c..e42374ef845 100644 --- a/pylint/pyreverse/vcg_printer.py +++ b/pylint/pyreverse/vcg_printer.py @@ -16,7 +16,8 @@ from collections.abc import Mapping from typing import Any -from pylint.pyreverse.printer import EdgeType, Layout, NodeProperties, NodeType, Printer +from pylint.pyreverse.printer import (EdgeType, Layout, NodeProperties, + NodeType, Printer) ATTRS_VAL = { "algos": ( diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index b19286a872a..c4ec4b1ffb2 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -13,14 +13,11 @@ from astroid import modutils, nodes -from pylint.pyreverse.diagrams import ( - ClassDiagram, - ClassEntity, - DiagramEntity, - PackageDiagram, - PackageEntity, -) -from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType, Printer +from pylint.pyreverse.diagrams import (ClassDiagram, ClassEntity, + DiagramEntity, PackageDiagram, + PackageEntity) +from pylint.pyreverse.printer import (EdgeType, NodeProperties, NodeType, + Printer) from pylint.pyreverse.printer_factory import get_printer_for_filetype from pylint.pyreverse.utils import is_exception diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py index 546b33378a3..0b575599117 100644 --- a/pylint/reporters/text.py +++ b/pylint/reporters/text.py @@ -15,7 +15,8 @@ import sys import warnings from dataclasses import asdict, fields -from typing import TYPE_CHECKING, Dict, NamedTuple, Optional, TextIO, cast, overload +from typing import (TYPE_CHECKING, Dict, NamedTuple, Optional, TextIO, cast, + overload) from pylint.message import Message from pylint.reporters import BaseReporter diff --git a/pylint/reporters/ureports/base_writer.py b/pylint/reporters/ureports/base_writer.py index e4bd7e7103a..3dfbec93e2b 100644 --- a/pylint/reporters/ureports/base_writer.py +++ b/pylint/reporters/ureports/base_writer.py @@ -16,13 +16,8 @@ from typing import TYPE_CHECKING, TextIO if TYPE_CHECKING: - from pylint.reporters.ureports.nodes import ( - BaseLayout, - EvaluationSection, - Paragraph, - Section, - Table, - ) + from pylint.reporters.ureports.nodes import (BaseLayout, EvaluationSection, + Paragraph, Section, Table) class BaseWriter: diff --git a/pylint/reporters/ureports/text_writer.py b/pylint/reporters/ureports/text_writer.py index 13c675aab9b..5bd967835e8 100644 --- a/pylint/reporters/ureports/text_writer.py +++ b/pylint/reporters/ureports/text_writer.py @@ -11,15 +11,9 @@ from pylint.reporters.ureports.base_writer import BaseWriter if TYPE_CHECKING: - from pylint.reporters.ureports.nodes import ( - EvaluationSection, - Paragraph, - Section, - Table, - Text, - Title, - VerbatimText, - ) + from pylint.reporters.ureports.nodes import (EvaluationSection, Paragraph, + Section, Table, Text, Title, + VerbatimText) TITLE_UNDERLINES = ["", "=", "-", "`", ".", "~", "^"] BULLETS = ["*", "-"] diff --git a/pylint/testutils/__init__.py b/pylint/testutils/__init__.py index e9b8de1de9c..3f3e330bcb1 100644 --- a/pylint/testutils/__init__.py +++ b/pylint/testutils/__init__.py @@ -29,7 +29,8 @@ from pylint.testutils.global_test_linter import linter from pylint.testutils.lint_module_test import LintModuleTest from pylint.testutils.output_line import MessageTest -from pylint.testutils.reporter_for_tests import GenericTestReporter, MinimalTestReporter +from pylint.testutils.reporter_for_tests import (GenericTestReporter, + MinimalTestReporter) from pylint.testutils.tokenize_str import _tokenize_str from pylint.testutils.unittest_linter import UnittestLinter from pylint.testutils.utils import create_files diff --git a/pylint/testutils/_primer/__init__.py b/pylint/testutils/_primer/__init__.py index 17c854572ec..fe38c179861 100644 --- a/pylint/testutils/_primer/__init__.py +++ b/pylint/testutils/_primer/__init__.py @@ -4,7 +4,5 @@ __all__ = ["PackageToLint", "PRIMER_DIRECTORY_PATH"] -from pylint.testutils._primer.package_to_lint import ( - PRIMER_DIRECTORY_PATH, - PackageToLint, -) +from pylint.testutils._primer.package_to_lint import (PRIMER_DIRECTORY_PATH, + PackageToLint) diff --git a/pylint/testutils/_primer/primer_compare_command.py b/pylint/testutils/_primer/primer_compare_command.py index 442ffa227a2..0228e38a91c 100644 --- a/pylint/testutils/_primer/primer_compare_command.py +++ b/pylint/testutils/_primer/primer_compare_command.py @@ -7,11 +7,9 @@ from pathlib import Path, PurePosixPath from pylint.reporters.json_reporter import OldJsonExport -from pylint.testutils._primer.primer_command import ( - PackageData, - PackageMessages, - PrimerCommand, -) +from pylint.testutils._primer.primer_command import (PackageData, + PackageMessages, + PrimerCommand) MAX_GITHUB_COMMENT_LENGTH = 65536 diff --git a/pylint/testutils/_primer/primer_run_command.py b/pylint/testutils/_primer/primer_run_command.py index cd17d6b1d8f..a632915a514 100644 --- a/pylint/testutils/_primer/primer_run_command.py +++ b/pylint/testutils/_primer/primer_run_command.py @@ -16,11 +16,9 @@ from pylint.reporters import JSONReporter from pylint.reporters.json_reporter import OldJsonExport from pylint.testutils._primer.package_to_lint import PackageToLint -from pylint.testutils._primer.primer_command import ( - PackageData, - PackageMessages, - PrimerCommand, -) +from pylint.testutils._primer.primer_command import (PackageData, + PackageMessages, + PrimerCommand) GITHUB_CRASH_TEMPLATE_LOCATION = "/home/runner/.cache" CRASH_TEMPLATE_INTRO = "There is a pre-filled template" diff --git a/pylint/testutils/functional/__init__.py b/pylint/testutils/functional/__init__.py index 4840e1ba646..d67d1f8cd98 100644 --- a/pylint/testutils/functional/__init__.py +++ b/pylint/testutils/functional/__init__.py @@ -13,11 +13,9 @@ from pylint.testutils.functional.find_functional_tests import ( REASONABLY_DISPLAYABLE_VERTICALLY, - get_functional_test_files_from_directory, -) -from pylint.testutils.functional.lint_module_output_update import LintModuleOutputUpdate -from pylint.testutils.functional.test_file import ( - FunctionalTestFile, - NoFileError, - parse_python_version, -) + get_functional_test_files_from_directory) +from pylint.testutils.functional.lint_module_output_update import \ + LintModuleOutputUpdate +from pylint.testutils.functional.test_file import (FunctionalTestFile, + NoFileError, + parse_python_version) diff --git a/pylint/testutils/functional_test_file.py b/pylint/testutils/functional_test_file.py index e2bd7f59bd5..22ad367dda1 100644 --- a/pylint/testutils/functional_test_file.py +++ b/pylint/testutils/functional_test_file.py @@ -10,11 +10,8 @@ import warnings -from pylint.testutils.functional import ( - FunctionalTestFile, - NoFileError, - parse_python_version, -) +from pylint.testutils.functional import (FunctionalTestFile, NoFileError, + parse_python_version) warnings.warn( "'pylint.testutils.functional_test_file' will be accessible from" diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index d05f7e481ec..e3dfab4ab02 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -24,10 +24,7 @@ from pylint.message.message import Message from pylint.testutils.constants import _EXPECTED_RE, _OPERATORS, UPDATE_OPTION from pylint.testutils.functional.test_file import ( # need to import from functional.test_file to avoid cyclic import - FunctionalTestFile, - NoFileError, - parse_python_version, -) + FunctionalTestFile, NoFileError, parse_python_version) from pylint.testutils.output_line import OutputLine from pylint.testutils.reporter_for_tests import FunctionalTestReporter diff --git a/pylint/typing.py b/pylint/typing.py index d62618605c5..2ce7fff8e20 100644 --- a/pylint/typing.py +++ b/pylint/typing.py @@ -9,19 +9,8 @@ import argparse import sys from pathlib import Path -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Iterable, - NamedTuple, - Optional, - Pattern, - Tuple, - Type, - Union, -) +from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, NamedTuple, + Optional, Pattern, Tuple, Type, Union) if sys.version_info >= (3, 8): from typing import Literal, Protocol, TypedDict diff --git a/pylint/utils/__init__.py b/pylint/utils/__init__.py index bc5011db955..c03b903e037 100644 --- a/pylint/utils/__init__.py +++ b/pylint/utils/__init__.py @@ -10,24 +10,12 @@ from pylint.utils.docs import print_full_documentation from pylint.utils.file_state import FileState from pylint.utils.linterstats import LinterStats, ModuleStats, merge_stats -from pylint.utils.utils import ( - HAS_ISORT_5, - IsortDriver, - _check_csv, - _format_option_value, - _splitstrip, - _unquote, - decoding_stream, - diff_string, - format_section, - get_global_option, - get_module_and_frameid, - get_rst_section, - get_rst_title, - normalize_text, - register_plugins, - tokenize_module, -) +from pylint.utils.utils import (HAS_ISORT_5, IsortDriver, _check_csv, + _format_option_value, _splitstrip, _unquote, + decoding_stream, diff_string, format_section, + get_global_option, get_module_and_frameid, + get_rst_section, get_rst_title, normalize_text, + register_plugins, tokenize_module) __all__ = [ "ASTWalker", diff --git a/pylint/utils/file_state.py b/pylint/utils/file_state.py index 19122b37391..6b8b9c99e3b 100644 --- a/pylint/utils/file_state.py +++ b/pylint/utils/file_state.py @@ -13,11 +13,8 @@ from astroid import nodes -from pylint.constants import ( - INCOMPATIBLE_WITH_USELESS_SUPPRESSION, - MSG_STATE_SCOPE_MODULE, - WarningScope, -) +from pylint.constants import (INCOMPATIBLE_WITH_USELESS_SUPPRESSION, + MSG_STATE_SCOPE_MODULE, WarningScope) if sys.version_info >= (3, 8): from typing import Literal diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index 054d307bc06..fca1562bbc5 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -24,17 +24,8 @@ import warnings from collections.abc import Sequence from io import BufferedReader, BytesIO -from typing import ( - TYPE_CHECKING, - Any, - List, - Pattern, - TextIO, - Tuple, - TypeVar, - Union, - overload, -) +from typing import (TYPE_CHECKING, Any, List, Pattern, TextIO, Tuple, TypeVar, + Union, overload) from astroid import Module, modutils, nodes diff --git a/tests/checkers/unittest_misc.py b/tests/checkers/unittest_misc.py index e360d3bb688..17771374117 100644 --- a/tests/checkers/unittest_misc.py +++ b/tests/checkers/unittest_misc.py @@ -5,7 +5,8 @@ """Tests for the misc checker.""" from pylint.checkers import misc -from pylint.testutils import CheckerTestCase, MessageTest, _tokenize_str, set_config +from pylint.testutils import (CheckerTestCase, MessageTest, _tokenize_str, + set_config) class TestFixme(CheckerTestCase): diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py index abeb9dcf8db..ff1bf0d6998 100644 --- a/tests/checkers/unittest_spelling.py +++ b/tests/checkers/unittest_spelling.py @@ -8,7 +8,8 @@ import pytest from pylint.checkers import spelling -from pylint.testutils import CheckerTestCase, MessageTest, _tokenize_str, set_config +from pylint.testutils import (CheckerTestCase, MessageTest, _tokenize_str, + set_config) # try to create enchant dictionary try: diff --git a/tests/config/test_find_default_config_files.py b/tests/config/test_find_default_config_files.py index 2fd66544d72..551f764dea8 100644 --- a/tests/config/test_find_default_config_files.py +++ b/tests/config/test_find_default_config_files.py @@ -18,7 +18,8 @@ from pytest import CaptureFixture from pylint import config, testutils -from pylint.config.find_default_config_files import _cfg_has_config, _toml_has_config +from pylint.config.find_default_config_files import (_cfg_has_config, + _toml_has_config) from pylint.lint.run import Run diff --git a/tests/config/test_functional_config_loading.py b/tests/config/test_functional_config_loading.py index 432bdc1a1a5..a9d97e9fa6c 100644 --- a/tests/config/test_functional_config_loading.py +++ b/tests/config/test_functional_config_loading.py @@ -26,11 +26,8 @@ from pytest import CaptureFixture, LogCaptureFixture from pylint.testutils.configuration_test import ( - PylintConfiguration, - get_expected_configuration, - get_expected_output, - run_using_a_configuration_file, -) + PylintConfiguration, get_expected_configuration, get_expected_output, + run_using_a_configuration_file) HERE = Path(__file__).parent USER_SPECIFIC_PATH = HERE.parent.parent diff --git a/tests/data/clientmodule_test.py b/tests/data/clientmodule_test.py index 35c39684b55..3ff2946950d 100644 --- a/tests/data/clientmodule_test.py +++ b/tests/data/clientmodule_test.py @@ -1,5 +1,6 @@ """ docstring for file clientmodule.py """ -from data.suppliermodule_test import Interface, DoNothing, DoNothing2 +from data.suppliermodule_test import DoNothing, DoNothing2, Interface + class Ancestor: """ Ancestor method """ diff --git a/tests/data/suppliermodule_test.py b/tests/data/suppliermodule_test.py index 9c8b05d5235..4017f6a6adb 100644 --- a/tests/data/suppliermodule_test.py +++ b/tests/data/suppliermodule_test.py @@ -1,6 +1,7 @@ """ file suppliermodule.py """ from typing import Optional + class Interface: def get_value(self): raise NotImplementedError diff --git a/tests/functional/a/abstract/abstract_abc_methods.py b/tests/functional/a/abstract/abstract_abc_methods.py index 4d4af2cdbe4..75937f30d19 100644 --- a/tests/functional/a/abstract/abstract_abc_methods.py +++ b/tests/functional/a/abstract/abstract_abc_methods.py @@ -3,6 +3,7 @@ import abc + class Parent: """Abstract Base Class """ __metaclass__ = abc.ABCMeta diff --git a/tests/functional/a/abstract/abstract_class_instantiated.py b/tests/functional/a/abstract/abstract_class_instantiated.py index 289870c9d4d..7e3bd8ff82a 100644 --- a/tests/functional/a/abstract/abstract_class_instantiated.py +++ b/tests/functional/a/abstract/abstract_class_instantiated.py @@ -8,6 +8,7 @@ import abc import weakref + from lala import Bala diff --git a/tests/functional/a/access/access_attr_before_def_false_positive.py b/tests/functional/a/access/access_attr_before_def_false_positive.py index ebdb76c6afb..d458c5819df 100644 --- a/tests/functional/a/access/access_attr_before_def_false_positive.py +++ b/tests/functional/a/access/access_attr_before_def_false_positive.py @@ -8,6 +8,7 @@ import telnetlib + class SeeTelnet(telnetlib.Telnet): """ Extension of telnetlib. diff --git a/tests/functional/a/alternative/alternative_union_syntax_error.py b/tests/functional/a/alternative/alternative_union_syntax_error.py index 9d1f42c225a..49915fd9c9c 100644 --- a/tests/functional/a/alternative/alternative_union_syntax_error.py +++ b/tests/functional/a/alternative/alternative_union_syntax_error.py @@ -10,7 +10,6 @@ from dataclasses import dataclass from typing import NamedTuple, TypedDict - Alias = str | typing.List[int] # [unsupported-binary-operation] lst = [typing.Dict[str, int] | None,] # [unsupported-binary-operation] diff --git a/tests/functional/a/alternative/alternative_union_syntax_py37.py b/tests/functional/a/alternative/alternative_union_syntax_py37.py index 3d9e577f141..edb53352285 100644 --- a/tests/functional/a/alternative/alternative_union_syntax_py37.py +++ b/tests/functional/a/alternative/alternative_union_syntax_py37.py @@ -6,12 +6,12 @@ """ # pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring,inherit-non-class,too-few-public-methods,line-too-long,unnecessary-direct-lambda-call from __future__ import annotations + import dataclasses import typing from dataclasses import dataclass from typing import NamedTuple, TypedDict - Alias = str | typing.List[int] # [unsupported-binary-operation] lst = [typing.Dict[str, int] | None,] # [unsupported-binary-operation] diff --git a/tests/functional/a/arguments.py b/tests/functional/a/arguments.py index 6929b985000..d6df7288e14 100644 --- a/tests/functional/a/arguments.py +++ b/tests/functional/a/arguments.py @@ -84,6 +84,7 @@ def method_tests(): # Test a regression (issue #234) import sys + class Text: """ Regression """ @@ -206,6 +207,7 @@ def namedtuple_replace_issue_1036(): from functools import partial + def some_func(first, second, third): return first + second + third diff --git a/tests/functional/a/assigning/assigning_non_slot.py b/tests/functional/a/assigning/assigning_non_slot.py index 1d498a16df1..c58fc6ef365 100644 --- a/tests/functional/a/assigning/assigning_non_slot.py +++ b/tests/functional/a/assigning/assigning_non_slot.py @@ -6,6 +6,7 @@ from missing import Unknown + class Empty: """ empty """ @@ -159,10 +160,7 @@ def test(self): # pylint: disable=wrong-import-order, wrong-import-position -from typing import ( - Generic, - TypeVar, -) +from typing import Generic, TypeVar TypeT = TypeVar('TypeT') diff --git a/tests/functional/a/assigning/assigning_non_slot_4509.py b/tests/functional/a/assigning/assigning_non_slot_4509.py index 797c6b083ec..950b2989aab 100644 --- a/tests/functional/a/assigning/assigning_non_slot_4509.py +++ b/tests/functional/a/assigning/assigning_non_slot_4509.py @@ -5,6 +5,7 @@ # https://github.com/PyCQA/astroid/issues/999 from typing import Generic, TypeVar + T = TypeVar("T") class Base(Generic[T]): diff --git a/tests/functional/a/await_outside_async.py b/tests/functional/a/await_outside_async.py index 2bc1267615a..714f38e0377 100644 --- a/tests/functional/a/await_outside_async.py +++ b/tests/functional/a/await_outside_async.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring,unused-variable import asyncio + async def nested(): return 42 diff --git a/tests/functional/b/bad_exception_cause.py b/tests/functional/b/bad_exception_cause.py index 8d8db3677af..6db3fc03b9a 100644 --- a/tests/functional/b/bad_exception_cause.py +++ b/tests/functional/b/bad_exception_cause.py @@ -2,7 +2,9 @@ # pylint: disable=unreachable, import-error, multiple-imports -import socket, unknown +import socket + +import unknown class ExceptionSubclass(Exception): diff --git a/tests/functional/b/bad_reversed_sequence.py b/tests/functional/b/bad_reversed_sequence.py index c4380491e9c..56b703ba7aa 100644 --- a/tests/functional/b/bad_reversed_sequence.py +++ b/tests/functional/b/bad_reversed_sequence.py @@ -1,7 +1,7 @@ """ Checks that reversed() receive proper argument """ # pylint: disable=missing-docstring # pylint: disable=too-few-public-methods -from collections import deque, OrderedDict +from collections import OrderedDict, deque from enum import IntEnum diff --git a/tests/functional/b/bad_thread_instantiation.py b/tests/functional/b/bad_thread_instantiation.py index 3c9aa5e55a2..d3a8ae936d8 100644 --- a/tests/functional/b/bad_thread_instantiation.py +++ b/tests/functional/b/bad_thread_instantiation.py @@ -1,7 +1,6 @@ # pylint: disable=missing-docstring, redundant-keyword-arg, invalid-name, line-too-long import threading - threading.Thread(lambda: None).run() # [bad-thread-instantiation] threading.Thread(None, lambda: None) threading.Thread(lambda: None, group=None) # [bad-thread-instantiation] diff --git a/tests/functional/b/builtin_module_test.py b/tests/functional/b/builtin_module_test.py index ae59217a044..8ac822932fd 100644 --- a/tests/functional/b/builtin_module_test.py +++ b/tests/functional/b/builtin_module_test.py @@ -1,6 +1,7 @@ """test import from a builtin module""" from __future__ import absolute_import + from math import log10 diff --git a/tests/functional/c/class_members_py30.py b/tests/functional/c/class_members_py30.py index 4566ff44e47..5db20b0f80c 100644 --- a/tests/functional/c/class_members_py30.py +++ b/tests/functional/c/class_members_py30.py @@ -1,6 +1,8 @@ """ Various tests for class members access. """ # pylint: disable=too-few-public-methods,import-error,missing-docstring, wrong-import-position,wrong-import-order, unnecessary-dunder-call from missing import Missing + + class MyClass: """class docstring""" @@ -31,6 +33,7 @@ def __init__(self): from abc import ABCMeta + class TestMetaclass(metaclass=ABCMeta): """ Test attribute access for metaclasses. """ diff --git a/tests/functional/c/consider/consider_using_sys_exit.py b/tests/functional/c/consider/consider_using_sys_exit.py index 524cf004dd7..ede3ac8018e 100644 --- a/tests/functional/c/consider/consider_using_sys_exit.py +++ b/tests/functional/c/consider/consider_using_sys_exit.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring, invalid-name, disallowed-name, redefined-builtin, unused-variable import sys + def foo(): exit() # [consider-using-sys-exit] diff --git a/tests/functional/c/consider/consider_using_with.py b/tests/functional/c/consider/consider_using_with.py index 3466e15c0af..bcb583d410c 100644 --- a/tests/functional/c/consider/consider_using_with.py +++ b/tests/functional/c/consider/consider_using_with.py @@ -8,7 +8,7 @@ import threading import urllib import zipfile -from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor +from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor def test_codecs_open(): diff --git a/tests/functional/d/dataclass_with_default_factory.py b/tests/functional/d/dataclass_with_default_factory.py index db392d8b7ff..fb8f6657cbb 100644 --- a/tests/functional/d/dataclass_with_default_factory.py +++ b/tests/functional/d/dataclass_with_default_factory.py @@ -2,8 +2,8 @@ # See issues: # - https://github.com/PyCQA/pylint/issues/2605 # - https://github.com/PyCQA/pylint/issues/2698 -from dataclasses import dataclass, field import dataclasses as dc +from dataclasses import dataclass, field from typing import cast diff --git a/tests/functional/d/dataclass_with_field.py b/tests/functional/d/dataclass_with_field.py index 9a807becbf4..950a6e03a9b 100644 --- a/tests/functional/d/dataclass_with_field.py +++ b/tests/functional/d/dataclass_with_field.py @@ -4,7 +4,8 @@ from dataclasses import field from typing import List -from pydantic.dataclasses import dataclass # [import-error] + +from pydantic.dataclasses import dataclass # [import-error] class Item: diff --git a/tests/functional/d/deprecated/deprecated_class_py33.py b/tests/functional/d/deprecated/deprecated_class_py33.py index 470e467baa7..19cc6c2b4fb 100644 --- a/tests/functional/d/deprecated/deprecated_class_py33.py +++ b/tests/functional/d/deprecated/deprecated_class_py33.py @@ -1,11 +1,8 @@ """Test deprecated classes from Python 3.3.""" # pylint: disable=unused-import,import-error,no-name-in-module,abstract-class-instantiated -from collections import Iterable # [deprecated-class] - -import collections.Set # [deprecated-class] - import collections - +import collections.Set # [deprecated-class] +from collections import Iterable # [deprecated-class] _ = collections.Awaitable() # [deprecated-class] diff --git a/tests/functional/d/deprecated/deprecated_decorators.py b/tests/functional/d/deprecated/deprecated_decorators.py index 800ba61715f..58f1544d440 100644 --- a/tests/functional/d/deprecated/deprecated_decorators.py +++ b/tests/functional/d/deprecated/deprecated_decorators.py @@ -3,6 +3,7 @@ import abc + class MyClass: @abc.abstractclassmethod # [deprecated-decorator] def my_method(cls): diff --git a/tests/functional/d/deprecated/deprecated_methods_py38.py b/tests/functional/d/deprecated/deprecated_methods_py38.py index 3a7dfe862bf..3dfd60ef0f8 100644 --- a/tests/functional/d/deprecated/deprecated_methods_py38.py +++ b/tests/functional/d/deprecated/deprecated_methods_py38.py @@ -8,6 +8,7 @@ import unittest import xml.etree.ElementTree + class MyTest(unittest.TestCase): def test(self): self.assert_(True) # [deprecated-method] diff --git a/tests/functional/d/deprecated/deprecated_methods_py39.py b/tests/functional/d/deprecated/deprecated_methods_py39.py index 9959b1c2a25..5c73bf965ab 100644 --- a/tests/functional/d/deprecated/deprecated_methods_py39.py +++ b/tests/functional/d/deprecated/deprecated_methods_py39.py @@ -1,4 +1,5 @@ """Test deprecated methods from Python 3.9.""" import binascii + binascii.b2a_hqx() # [deprecated-method] diff --git a/tests/functional/d/deprecated/deprecated_module_py3.py b/tests/functional/d/deprecated/deprecated_module_py3.py index 308d400e771..b01fbcb33d9 100644 --- a/tests/functional/d/deprecated/deprecated_module_py3.py +++ b/tests/functional/d/deprecated/deprecated_module_py3.py @@ -1,4 +1,4 @@ """Test deprecated modules.""" # pylint: disable=unused-import -import optparse # [deprecated-module] +import optparse # [deprecated-module] diff --git a/tests/functional/d/deprecated/deprecated_module_py36.py b/tests/functional/d/deprecated/deprecated_module_py36.py index c49f9f0bcbd..3f3b16d126f 100644 --- a/tests/functional/d/deprecated/deprecated_module_py36.py +++ b/tests/functional/d/deprecated/deprecated_module_py36.py @@ -1,4 +1,4 @@ """Test deprecated modules from Python 3.6.""" # pylint: disable=unused-import,import-error -import optparse # [deprecated-module] +import optparse # [deprecated-module] diff --git a/tests/functional/d/deprecated/deprecated_module_py4.py b/tests/functional/d/deprecated/deprecated_module_py4.py index 3cad959e75b..4518504df8a 100644 --- a/tests/functional/d/deprecated/deprecated_module_py4.py +++ b/tests/functional/d/deprecated/deprecated_module_py4.py @@ -1,4 +1,4 @@ """Test deprecated modules.""" -from deprecated import foo # [deprecated-module] import deprecated # [deprecated-module] +from deprecated import foo # [deprecated-module] diff --git a/tests/functional/d/deprecated/deprecated_module_uninstalled.py b/tests/functional/d/deprecated/deprecated_module_uninstalled.py index 52d55fa840b..da46eb55a1a 100644 --- a/tests/functional/d/deprecated/deprecated_module_uninstalled.py +++ b/tests/functional/d/deprecated/deprecated_module_uninstalled.py @@ -1,5 +1,5 @@ """Test deprecated modules uninstalled.""" # pylint: disable=unused-import,no-name-in-module,import-error -from uninstalled import uninstalled_module # [deprecated-module] -import uninstalled # [deprecated-module] +import uninstalled # [deprecated-module] +from uninstalled import uninstalled_module # [deprecated-module] diff --git a/tests/functional/d/deprecated/deprecated_relative_import/dot_relative_import.py b/tests/functional/d/deprecated/deprecated_relative_import/dot_relative_import.py index db07f976beb..acabc184aac 100644 --- a/tests/functional/d/deprecated/deprecated_relative_import/dot_relative_import.py +++ b/tests/functional/d/deprecated/deprecated_relative_import/dot_relative_import.py @@ -1,7 +1,8 @@ # pylint: disable=import-error, missing-module-docstring, unused-import # from import of stdlib optparse which should yield deprecated-module error -from optparse import OptionParser # [deprecated-module] +from optparse import OptionParser # [deprecated-module] + # from import of module internal optparse module inside this package. # This should not yield deprecated-module error from .optparse import Bar diff --git a/tests/functional/d/deprecated/deprecated_relative_import/subpackage/dot_dot_relative_import.py b/tests/functional/d/deprecated/deprecated_relative_import/subpackage/dot_dot_relative_import.py index 359a4c46d9e..bc1a14cd8c5 100644 --- a/tests/functional/d/deprecated/deprecated_relative_import/subpackage/dot_dot_relative_import.py +++ b/tests/functional/d/deprecated/deprecated_relative_import/subpackage/dot_dot_relative_import.py @@ -1,7 +1,8 @@ # pylint: disable=import-error, unused-import, missing-module-docstring # from import of stdlib optparse which should yield deprecated-module error -from optparse import OptionParser # [deprecated-module] +from optparse import OptionParser # [deprecated-module] + # from import of module internal optparse module inside this package. # This should not yield deprecated-module error from ..optparse import Bar diff --git a/tests/functional/d/disable_ungrouped_imports.py b/tests/functional/d/disable_ungrouped_imports.py index 48c06c01ca4..90dea85432a 100644 --- a/tests/functional/d/disable_ungrouped_imports.py +++ b/tests/functional/d/disable_ungrouped_imports.py @@ -2,9 +2,9 @@ imports from being considered ungrouped in respect to it.""" # pylint: disable=unused-import,wrong-import-position,wrong-import-order,using-constant-test # pylint: disable=import-error -from os.path import basename +import logging import logging.config # pylint: disable=ungrouped-imports +import logging.handlers # [ungrouped-imports] import os.path -import logging from os.path import join # [ungrouped-imports] -import logging.handlers # [ungrouped-imports] +from os.path import basename diff --git a/tests/functional/d/disable_wrong_import_order.py b/tests/functional/d/disable_wrong_import_order.py index 1fdf83fb100..20ef651faae 100644 --- a/tests/functional/d/disable_wrong_import_order.py +++ b/tests/functional/d/disable_wrong_import_order.py @@ -3,9 +3,10 @@ it from being considered for 'ungrouped-imports'.""" # pylint: disable=unused-import,import-error,no-name-in-module -from first_party.foo import bar # pylint: disable=wrong-import-order import logging import os.path import sys + from astroid import are_exclusive -from first_party.bar import foo # [ungrouped-imports] +from first_party.bar import foo # [ungrouped-imports] +from first_party.foo import bar # pylint: disable=wrong-import-order diff --git a/tests/functional/e/enum_self_defined_member_5138.py b/tests/functional/e/enum_self_defined_member_5138.py index 4a49903c631..25622617cc9 100644 --- a/tests/functional/e/enum_self_defined_member_5138.py +++ b/tests/functional/e/enum_self_defined_member_5138.py @@ -1,6 +1,6 @@ """Tests for self-defined Enum members (https://github.com/PyCQA/pylint/issues/5138)""" # pylint: disable=missing-docstring -from enum import IntEnum, Enum +from enum import Enum, IntEnum class Day(IntEnum): diff --git a/tests/functional/ext/check_elif/check_elif.py b/tests/functional/ext/check_elif/check_elif.py index f10e78511c8..680e195abc0 100644 --- a/tests/functional/ext/check_elif/check_elif.py +++ b/tests/functional/ext/check_elif/check_elif.py @@ -1,7 +1,7 @@ # pylint: disable=no-else-raise,unsupported-membership-test,using-constant-test, comparison-of-constants """Checks use of "else if" triggers a refactor message""" -from typing import Union, Sequence, Any, Mapping +from typing import Any, Mapping, Sequence, Union def my_function(): diff --git a/tests/functional/ext/code_style/cs_consider_using_namedtuple_or_dataclass.py b/tests/functional/ext/code_style/cs_consider_using_namedtuple_or_dataclass.py index 627de76842a..c6b62aa5a3e 100644 --- a/tests/functional/ext/code_style/cs_consider_using_namedtuple_or_dataclass.py +++ b/tests/functional/ext/code_style/cs_consider_using_namedtuple_or_dataclass.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring,too-few-public-methods,unused-variable,no-name-in-module from typing import Final + class Foo: BAR = "bar" diff --git a/tests/functional/ext/private_import/private_import.py b/tests/functional/ext/private_import/private_import.py index 917e01c9c2a..a064e093e40 100644 --- a/tests/functional/ext/private_import/private_import.py +++ b/tests/functional/ext/private_import/private_import.py @@ -3,24 +3,26 @@ # pylint: disable=no-name-in-module, multiple-imports, ungrouped-imports, misplaced-future # pylint: disable=wrong-import-position, relative-beyond-top-level -# Basic cases -from _world import hello # [import-private-name] -from _world import _hello # [import-private-name] -from city import _house # [import-private-name] -from city import a, _b, c, _d # [import-private-name] -from _city import a, _b, c, _d # [import-private-name] -from city import a, b, c, _d # [import-private-name] -import house -import _house # [import-private-name] -import _house, _chair, _stair # [import-private-name] -import house, _chair, _stair # [import-private-name] +import __future__ +from __future__ import __print_function__, print_function + +from sys import _private # [import-private-name] +# Ignore typecheck +from typing import TYPE_CHECKING, List, Optional # Ignore dunders import __asd__ -import __future__ -from __future__ import print_function -from __future__ import __print_function__ - +import _chair +import _house # [import-private-name] +import _stair +import house # [import-private-name] +from _city import _b, _d, a, c # [import-private-name] +# Basic cases +from _world import _hello # [import-private-name] +from _world import hello # [import-private-name] +from astroid import _private # [import-private-name] +from city import _house # [import-private-name] +from city import _b, _d, a, b, c # [import-private-name] # Ignore local modules # The check for local modules compares directory names in the path of the file being linted to # the name of the module we are importing from. The use of `__init__.py` to indicate Python modules @@ -30,23 +32,17 @@ # we are not importing from that directory. (We would be importing from `pylint/pylint`.) from private_import import _private # pylint: disable=import-self from private_import.other_file import _private -from . import _private -from astroid import _private # [import-private-name] -from sys import _private # [import-private-name] -# Ignore typecheck -from typing import TYPE_CHECKING, List, Optional +from . import _private if TYPE_CHECKING: - import _TreeType from types import _TreeType - from _types import TreeType - from _types import _TreeType + + import _TreeType + from _types import TreeType, _TreeType # No error since imports are used as type annotations -from classes import _PrivateClassA, safe_get_A -from classes import _PrivateClassB -from classes import _PrivateClassC +from classes import _PrivateClassA, _PrivateClassB, _PrivateClassC, safe_get_A a_var: _PrivateClassA = safe_get_A() @@ -57,8 +53,7 @@ def c_func() -> _PrivateClassC: return None # Used as typing in slices -from classes import _SubScriptA -from classes import _SubScriptB +from classes import _SubScriptA, _SubScriptB a: Optional[_SubScriptA] b: Optional[_SubScriptB[List]] @@ -66,8 +61,8 @@ def c_func() -> _PrivateClassC: import _TypeContainerA import _TypeContainerB import _TypeContainerC - import SafeContainerA + a2: _TypeContainerA.A = SafeContainerA.safe_get_a() def b_func2(class_b2: _TypeContainerB.B): @@ -79,44 +74,55 @@ def c2_func() -> _TypeContainerC.C: # This is allowed since all the imports are used for typing from _TypeContainerExtra import TypeExtraA, TypeExtraB from MakerContainerExtra import GetA, GetB + extraA: TypeExtraA = GetA() extraB: TypeExtraB = GetB() # This is not allowed because there is an import not used for typing -from _TypeContainerExtra2 import TypeExtra2, NotTypeExtra # [import-private-name] +from _TypeContainerExtra2 import (NotTypeExtra, # [import-private-name] + TypeExtra2) + extra2: TypeExtra2 # Try many cases to ensure that type annotation usages of a private import # do not mask other illegal usages of the import -import _private_module # [import-private-name] +import _private_module # [import-private-name] + my_var: _private_module.Thing = _private_module.Thing() -import _private_module2 # [import-private-name] +import _private_module2 # [import-private-name] + my_var2: _private_module2.Thing2 my_var2 = _private_module2.Thing2() -import _private_module3 # [import-private-name] +import _private_module3 # [import-private-name] + my_var3: _private_module3.Thing3 my_var3 = _private_module3.Thing3 my_var3_2: _private_module3.Thing3 -import _private_module4 # [import-private-name] +import _private_module4 # [import-private-name] + my_var4: _private_module4.Thing4 my_var4 = _private_module4.get_callers().get_thing4() -from _private_module5 import PrivateClass # [import-private-name] +from _private_module5 import PrivateClass # [import-private-name] + my_var5: PrivateClass my_var5 = PrivateClass() -from _private_module6 import PrivateClass2 # [import-private-name] +from _private_module6 import PrivateClass2 # [import-private-name] + my_var6: PrivateClass2 = PrivateClass2() -from public_module import _PrivateClass3 # [import-private-name] +from public_module import _PrivateClass3 # [import-private-name] + my_var7: _PrivateClass3 = _PrivateClass3() # Even though we do not see the private call, the type check does not keep us from emitting # because we do not use that variable -import _private_module_unreachable # [import-private-name] +import _private_module_unreachable # [import-private-name] + my_var8: _private_module_unreachable.Thing8 _private_module_unreachable.Thing8() @@ -134,6 +140,6 @@ def save(self): return self +from ..parent import _private # Treat relative imports as internal from .other_file import _private -from ..parent import _private diff --git a/tests/functional/ext/redefined_variable_type/regression_newtype_fstring.py b/tests/functional/ext/redefined_variable_type/regression_newtype_fstring.py index 1e3cb28080d..6d4ff2a471e 100644 --- a/tests/functional/ext/redefined_variable_type/regression_newtype_fstring.py +++ b/tests/functional/ext/redefined_variable_type/regression_newtype_fstring.py @@ -3,6 +3,7 @@ """ from typing import NewType + def make_new_type(suffix): """Dynamically create a NewType with `suffix`""" new_type = NewType(f'IntRange_{suffix}', suffix) diff --git a/tests/functional/ext/typing/typing_consider_using_alias.py b/tests/functional/ext/typing/typing_consider_using_alias.py index 9fe636a96f4..5436cf1478f 100644 --- a/tests/functional/ext/typing/typing_consider_using_alias.py +++ b/tests/functional/ext/typing/typing_consider_using_alias.py @@ -11,7 +11,7 @@ import typing from collections.abc import Awaitable from dataclasses import dataclass -from typing import Dict, List, Set, Union, TypedDict, Callable, Tuple, Type +from typing import Callable, Dict, List, Set, Tuple, Type, TypedDict, Union var1: typing.Dict[str, int] # [consider-using-alias] var2: List[int] # [consider-using-alias] diff --git a/tests/functional/ext/typing/typing_consider_using_alias_without_future.py b/tests/functional/ext/typing/typing_consider_using_alias_without_future.py index 17daab99395..7b8f4a9253e 100644 --- a/tests/functional/ext/typing/typing_consider_using_alias_without_future.py +++ b/tests/functional/ext/typing/typing_consider_using_alias_without_future.py @@ -8,7 +8,7 @@ import typing from collections.abc import Awaitable from dataclasses import dataclass -from typing import Dict, List, Set, Union, TypedDict, Callable, Tuple, Type +from typing import Callable, Dict, List, Set, Tuple, Type, TypedDict, Union var1: typing.Dict[str, int] # [consider-using-alias] var2: List[int] # [consider-using-alias] diff --git a/tests/functional/ext/typing/typing_consider_using_union.py b/tests/functional/ext/typing/typing_consider_using_union.py index bb92e6fc70e..a8178bdba4a 100644 --- a/tests/functional/ext/typing/typing_consider_using_union.py +++ b/tests/functional/ext/typing/typing_consider_using_union.py @@ -6,9 +6,10 @@ # pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long # pylint: disable=consider-using-alias,unnecessary-direct-lambda-call from __future__ import annotations -from dataclasses import dataclass + import typing -from typing import Dict, List, Optional, Union, TypedDict +from dataclasses import dataclass +from typing import Dict, List, Optional, TypedDict, Union var1: Union[int, str] # [consider-alternative-union-syntax] var2: List[Union[int, None]] # [consider-alternative-union-syntax] diff --git a/tests/functional/ext/typing/typing_consider_using_union_py310.py b/tests/functional/ext/typing/typing_consider_using_union_py310.py index 2c661f152c2..ee474637ad3 100644 --- a/tests/functional/ext/typing/typing_consider_using_union_py310.py +++ b/tests/functional/ext/typing/typing_consider_using_union_py310.py @@ -2,11 +2,11 @@ 'py-version' needs to be set to >= '3.10'. """ +import typing # pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long # pylint: disable=deprecated-typing-alias,unnecessary-direct-lambda-call from dataclasses import dataclass -import typing -from typing import Dict, List, Optional, Union, TypedDict +from typing import Dict, List, Optional, TypedDict, Union var1: Union[int, str] # [consider-alternative-union-syntax] var2: List[Union[int, None]] # [consider-alternative-union-syntax] diff --git a/tests/functional/ext/typing/typing_consider_using_union_without_future.py b/tests/functional/ext/typing/typing_consider_using_union_without_future.py index 1fb43c65ace..3b44a24ea8a 100644 --- a/tests/functional/ext/typing/typing_consider_using_union_without_future.py +++ b/tests/functional/ext/typing/typing_consider_using_union_without_future.py @@ -2,11 +2,11 @@ 'py-version' needs to be set to >= '3.7' and 'runtime-typing=no'. """ +import typing # pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long,unnecessary-direct-lambda-call # pylint: disable=consider-using-alias from dataclasses import dataclass -import typing -from typing import Dict, List, Optional, Union, TypedDict +from typing import Dict, List, Optional, TypedDict, Union var1: Union[int, str] # [consider-alternative-union-syntax] var2: List[Union[int, None]] # [consider-alternative-union-syntax] diff --git a/tests/functional/ext/typing/typing_deprecated_alias.py b/tests/functional/ext/typing/typing_deprecated_alias.py index 80c132ebd90..ff6b2a9213e 100644 --- a/tests/functional/ext/typing/typing_deprecated_alias.py +++ b/tests/functional/ext/typing/typing_deprecated_alias.py @@ -8,7 +8,7 @@ import typing from collections.abc import Awaitable from dataclasses import dataclass -from typing import Dict, List, Set, Union, TypedDict, Callable, Tuple, Type +from typing import Callable, Dict, List, Set, Tuple, Type, TypedDict, Union var1: typing.Dict[str, int] # [deprecated-typing-alias] var2: List[int] # [deprecated-typing-alias] diff --git a/tests/functional/f/fallback_import_disabled.py b/tests/functional/f/fallback_import_disabled.py index 321eb115821..c9a5f3d33cb 100644 --- a/tests/functional/f/fallback_import_disabled.py +++ b/tests/functional/f/fallback_import_disabled.py @@ -1,10 +1,10 @@ # pylint: disable=missing-docstring,unused-import try: - import urllib2 as urllib_request #@ + import urllib2 as urllib_request # @ import urllib2 as urllib_error from urlparse import urlparse except ImportError: # python2 - from urllib import request as urllib_request from urllib import error as urllib_error + from urllib import request as urllib_request from urllib.parse import urlparseq diff --git a/tests/functional/f/fallback_import_enabled.py b/tests/functional/f/fallback_import_enabled.py index 9420830ffad..89a0be40de8 100644 --- a/tests/functional/f/fallback_import_enabled.py +++ b/tests/functional/f/fallback_import_enabled.py @@ -1,5 +1,5 @@ # pylint: disable=missing-docstring,unused-import try: - import collections.missing # [no-name-in-module] + import collections.missing # [no-name-in-module] except ImportError: - from collections import missing # [no-name-in-module] + from collections import missing # [no-name-in-module] diff --git a/tests/functional/f/function_redefined.py b/tests/functional/f/function_redefined.py index a87c79680a7..d37ba2d183d 100644 --- a/tests/functional/f/function_redefined.py +++ b/tests/functional/f/function_redefined.py @@ -86,14 +86,20 @@ def dummy_func(): pass from math import ceil + + def ceil(): # [function-redefined] pass import math + + def math(): # [function-redefined] pass import math as _ + + def _(): pass diff --git a/tests/functional/f/future_unicode_literals.py b/tests/functional/f/future_unicode_literals.py index 30c2bd6b3f2..7e7332cbe03 100644 --- a/tests/functional/f/future_unicode_literals.py +++ b/tests/functional/f/future_unicode_literals.py @@ -1,6 +1,5 @@ """Unicode literals in Python 2.*""" from __future__ import unicode_literals - BAD_STRING = b'\u1234' # >= 2.7.4:[anomalous-unicode-escape-in-string] GOOD_STRING = '\u1234' diff --git a/tests/functional/g/generated_members.py b/tests/functional/g/generated_members.py index ffb3de6314f..c8dba404f21 100644 --- a/tests/functional/g/generated_members.py +++ b/tests/functional/g/generated_members.py @@ -1,9 +1,12 @@ """Test the generated-members config option.""" # pylint: disable=pointless-statement, invalid-name from __future__ import annotations + from astroid import nodes + from pylint import checkers + class Klass: """A class with a generated member.""" diff --git a/tests/functional/g/generic_alias/generic_alias_postponed_evaluation_py37.py b/tests/functional/g/generic_alias/generic_alias_postponed_evaluation_py37.py index 02cbcf081cd..f76ac33c121 100644 --- a/tests/functional/g/generic_alias/generic_alias_postponed_evaluation_py37.py +++ b/tests/functional/g/generic_alias/generic_alias_postponed_evaluation_py37.py @@ -14,7 +14,6 @@ import contextlib import re - # ----- unsubscriptable (even with postponed evaluation) ----- # special tuple[int, int] # [unsubscriptable-object] diff --git a/tests/functional/g/generic_alias/generic_alias_related.py b/tests/functional/g/generic_alias/generic_alias_related.py index a5b917c73b5..f6959bd4c12 100644 --- a/tests/functional/g/generic_alias/generic_alias_related.py +++ b/tests/functional/g/generic_alias/generic_alias_related.py @@ -5,11 +5,11 @@ - `__class_getitem__` - `metaclass=ABCMeta` """ +import typing # flake8: noqa # pylint: disable=missing-docstring,pointless-statement,expression-not-assigned # pylint: disable=too-few-public-methods,multiple-statements,line-too-long, unnecessary-lambda-assignment from abc import ABCMeta, abstractmethod -import typing class ClsUnsubscriptable: diff --git a/tests/functional/g/generic_alias/generic_alias_related_py39.py b/tests/functional/g/generic_alias/generic_alias_related_py39.py index 14445a043fe..4ceec360a89 100644 --- a/tests/functional/g/generic_alias/generic_alias_related_py39.py +++ b/tests/functional/g/generic_alias/generic_alias_related_py39.py @@ -5,11 +5,11 @@ - `__class_getitem__` - `metaclass=ABCMeta` """ +import typing # flake8: noqa # pylint: disable=missing-docstring,pointless-statement,expression-not-assigned # pylint: disable=too-few-public-methods,multiple-statements,line-too-long from abc import ABCMeta, abstractmethod -import typing GenericAlias = type(list[int]) diff --git a/tests/functional/g/generic_alias/generic_alias_side_effects.py b/tests/functional/g/generic_alias/generic_alias_side_effects.py index 344db955313..258b09dc78d 100644 --- a/tests/functional/g/generic_alias/generic_alias_side_effects.py +++ b/tests/functional/g/generic_alias/generic_alias_side_effects.py @@ -1,9 +1,8 @@ # pylint: disable=missing-docstring,invalid-name,line-too-long,too-few-public-methods,use-list-literal,use-dict-literal, typevar-name-incorrect-variance -import typing import collections +import typing from typing import Generic, TypeVar - # tests/functional/a/assigning_non_slot.py TYPE = TypeVar('TYPE') diff --git a/tests/functional/i/import_aliasing.py b/tests/functional/i/import_aliasing.py index 3926534f101..3ee382dd373 100644 --- a/tests/functional/i/import_aliasing.py +++ b/tests/functional/i/import_aliasing.py @@ -3,24 +3,27 @@ # 1. useless-import-alias # 2. consider-using-from-import -from collections import OrderedDict as OrderedDict # [useless-import-alias] -from collections import OrderedDict as o_dict -import os.path as path # [consider-using-from-import] -import os.path as p -import foo.bar.foobar as foobar # [consider-using-from-import] import os import os as OS +import os.path as path # [consider-using-from-import] +import os.path as p +from collections import OrderedDict as OrderedDict # [useless-import-alias] +from collections import OrderedDict as o_dict from sys import version -from . import bar as bar # [useless-import-alias] + +import foo.bar.foobar as foobar # [consider-using-from-import] +from foo.bar import foobar as foo # [useless-import-alias] +from foo.bar import foobar as foobar + +from ............a import b # [relative-beyond-top-level] +from ..foo import bar as bar # [useless-import-alias] +from ..foo.bar import foobar as anotherfoobar # [useless-import-alias] +from ..foo.bar import foobar as foobar +from . import bar # [useless-import-alias] from . import bar as Bar -from . import bar -from ..foo import bar as bar # [useless-import-alias] -from ..foo.bar import foobar as foobar # [useless-import-alias] -from ..foo.bar import foobar as anotherfoobar -from . import foo as foo, foo2 as bar2 # [useless-import-alias] -from . import foo as bar, foo2 as foo2 # [useless-import-alias] -from . import foo as bar, foo2 as bar2 -from foo.bar import foobar as foobar # [useless-import-alias] -from foo.bar import foobar as foo +from . import bar as bar +from . import foo as bar # [useless-import-alias] +from . import foo as foo +from . import foo2 as bar2 +from . import foo2 as foo2 from .foo.bar import f as foobar -from ............a import b # [relative-beyond-top-level] diff --git a/tests/functional/i/import_error.py b/tests/functional/i/import_error.py index 12f56f9eac9..296005c57f1 100644 --- a/tests/functional/i/import_error.py +++ b/tests/functional/i/import_error.py @@ -1,6 +1,6 @@ """ Test that import errors are detected. """ # pylint: disable=invalid-name, unused-import, bare-except, broad-except, wrong-import-order, wrong-import-position -import totally_missing # [import-error] +import totally_missing # [import-error] try: import maybe_missing @@ -18,7 +18,7 @@ maybe_missing_1 = None try: - import maybe_missing_2 # [import-error] + import maybe_missing_2 # [import-error] except ValueError: maybe_missing_2 = None @@ -30,9 +30,6 @@ pass -from functional.s.syntax.syntax_error import toto # [no-name-in-module,syntax-error] - - # Don't emit `import-error` or `no-name-in-module` # if guarded behind `sys.version_info` or `typing.TYPE_CHECKING` import sys @@ -40,6 +37,8 @@ import typing as tp # pylint: disable=reimported from typing import TYPE_CHECKING +from functional.s.syntax.syntax_error import \ + toto # [no-name-in-module,syntax-error] if sys.version_info >= (3, 9): import some_module @@ -65,24 +64,18 @@ # Test ignore-modules option -from external_module import anything - -from external_module.another_module import anything +# Issues with contextlib.suppress reported in +# https://github.com/PyCQA/pylint/issues/7270 +import contextlib +import bar import external_module - +import foo # [multiple-imports] +from external_module import anything +from external_module.another_module import anything from fake_module.submodule import anything - from fake_module.submodule.deeper import anything -import foo, bar # [multiple-imports] - -import foo -import bar - -# Issues with contextlib.suppress reported in -# https://github.com/PyCQA/pylint/issues/7270 -import contextlib with contextlib.suppress(ImportError): import foo2 diff --git a/tests/functional/i/import_outside_toplevel.py b/tests/functional/i/import_outside_toplevel.py index 455d693527d..f3f0e261418 100644 --- a/tests/functional/i/import_outside_toplevel.py +++ b/tests/functional/i/import_outside_toplevel.py @@ -12,7 +12,8 @@ def f(): def g(): - import os, sys # [import-outside-toplevel] + import os # [import-outside-toplevel] + import sys def h(): @@ -20,7 +21,8 @@ def h(): def i(): - import random as rand, socket as sock # [import-outside-toplevel] + import random as rand # [import-outside-toplevel] + import socket as sock class C: @@ -36,11 +38,12 @@ def k(flag): def j(): - from collections import defaultdict # [import-outside-toplevel] + from collections import defaultdict # [import-outside-toplevel] def m(): - from math import sin as sign, cos as cosplay # [import-outside-toplevel] + from math import cos as cosplay + from math import sin as sign # [import-outside-toplevel] # Test allow-any-import-level setting diff --git a/tests/functional/i/inconsistent/inconsistent_returns.py b/tests/functional/i/inconsistent/inconsistent_returns.py index c1183b288ed..38970622757 100644 --- a/tests/functional/i/inconsistent/inconsistent_returns.py +++ b/tests/functional/i/inconsistent/inconsistent_returns.py @@ -4,6 +4,7 @@ import math import sys + # These ones are consistent def explicit_returns(var): if var >= 0: diff --git a/tests/functional/i/inconsistent/inconsistent_returns_noreturn.py b/tests/functional/i/inconsistent/inconsistent_returns_noreturn.py index 768d6e65852..f55a6887b79 100644 --- a/tests/functional/i/inconsistent/inconsistent_returns_noreturn.py +++ b/tests/functional/i/inconsistent/inconsistent_returns_noreturn.py @@ -4,6 +4,7 @@ import sys import typing + def parser_error(msg) -> typing.NoReturn: # pylint: disable=unused-argument sys.exit(1) @@ -13,6 +14,7 @@ def parser_error_nortype(msg): # pylint: disable=unused-argument from typing import NoReturn # pylint: disable=wrong-import-position + def parser_error_name(msg) -> NoReturn: # pylint: disable=unused-argument sys.exit(3) diff --git a/tests/functional/i/inference_crash_4692.py b/tests/functional/i/inference_crash_4692.py index 5e990aaa700..ffd23a1d476 100644 --- a/tests/functional/i/inference_crash_4692.py +++ b/tests/functional/i/inference_crash_4692.py @@ -4,6 +4,5 @@ # does not appear if click is installed (astroid can analyse it) import notclick # [import-error] - for name, item in notclick.__dict__.items(): _ = isinstance(item, notclick.Command) and item != 'foo' diff --git a/tests/functional/i/invalid/invalid_bool_returned.py b/tests/functional/i/invalid/invalid_bool_returned.py index eb888155b34..fe4d4aad884 100644 --- a/tests/functional/i/invalid/invalid_bool_returned.py +++ b/tests/functional/i/invalid/invalid_bool_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_bytes_returned.py b/tests/functional/i/invalid/invalid_bytes_returned.py index 5ba83252318..0a8d36f1e9b 100644 --- a/tests/functional/i/invalid/invalid_bytes_returned.py +++ b/tests/functional/i/invalid/invalid_bytes_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_enum_extension.py b/tests/functional/i/invalid/invalid_enum_extension.py index 5af11af387f..e9e3f492b64 100644 --- a/tests/functional/i/invalid/invalid_enum_extension.py +++ b/tests/functional/i/invalid/invalid_enum_extension.py @@ -2,6 +2,7 @@ # pylint: disable=missing-class-docstring,invalid-name from enum import Enum, IntFlag + # We don't flag the Enum class itself class A(Enum): x = 1 diff --git a/tests/functional/i/invalid/invalid_exceptions/invalid_exceptions_caught.py b/tests/functional/i/invalid/invalid_exceptions/invalid_exceptions_caught.py index 1b513f97243..187d5dffe20 100644 --- a/tests/functional/i/invalid/invalid_exceptions/invalid_exceptions_caught.py +++ b/tests/functional/i/invalid/invalid_exceptions/invalid_exceptions_caught.py @@ -1,7 +1,12 @@ # pylint: disable=missing-docstring, too-few-public-methods, use-list-literal # pylint: disable=too-many-ancestors, import-error, multiple-imports,wrong-import-position -import socket, binascii, abc, six +import abc +import binascii +import socket + +import six + class MyException: """Custom 'exception'.""" @@ -85,6 +90,7 @@ class SecondSkipException(SkipException): print("caught") from missing_import import UnknownError + UNKNOWN_COMPONENTS = (ZeroDivisionError, UnknownError) try: diff --git a/tests/functional/i/invalid/invalid_format_returned.py b/tests/functional/i/invalid/invalid_format_returned.py index f97d0f29d5e..2daf2c4aedc 100644 --- a/tests/functional/i/invalid/invalid_format_returned.py +++ b/tests/functional/i/invalid/invalid_format_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_ex_returned.py b/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_ex_returned.py index efe6ba25fbe..da9e564cc4e 100644 --- a/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_ex_returned.py +++ b/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_ex_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,use-dict-literal,unnecessary-lambda-assignment,use-dict-literal import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_returned.py b/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_returned.py index 06cd81dd081..c2535f1fc98 100644 --- a/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_returned.py +++ b/tests/functional/i/invalid/invalid_getnewargs/invalid_getnewargs_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment,use-dict-literal import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_hash_returned.py b/tests/functional/i/invalid/invalid_hash_returned.py index 4fedb63bc91..68cc759da71 100644 --- a/tests/functional/i/invalid/invalid_hash_returned.py +++ b/tests/functional/i/invalid/invalid_hash_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_index_returned.py b/tests/functional/i/invalid/invalid_index_returned.py index 83c7fb02bdf..589277a35f0 100644 --- a/tests/functional/i/invalid/invalid_index_returned.py +++ b/tests/functional/i/invalid/invalid_index_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_length/invalid_length_hint_returned.py b/tests/functional/i/invalid/invalid_length/invalid_length_hint_returned.py index e8178863ca3..c2194ce4977 100644 --- a/tests/functional/i/invalid/invalid_length/invalid_length_hint_returned.py +++ b/tests/functional/i/invalid/invalid_length/invalid_length_hint_returned.py @@ -4,7 +4,6 @@ import sys import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_length/invalid_length_returned.py b/tests/functional/i/invalid/invalid_length/invalid_length_returned.py index 14758687d5f..b467b1ce315 100644 --- a/tests/functional/i/invalid/invalid_length/invalid_length_returned.py +++ b/tests/functional/i/invalid/invalid_length/invalid_length_returned.py @@ -4,7 +4,6 @@ import sys import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_name.py b/tests/functional/i/invalid/invalid_name.py index 201d5bf9f39..30ab8cdcfea 100644 --- a/tests/functional/i/invalid/invalid_name.py +++ b/tests/functional/i/invalid/invalid_name.py @@ -16,7 +16,8 @@ time = None # [invalid-name] try: - from sys import argv, executable as python + from sys import argv + from sys import executable as python except ImportError: argv = 42 python = 24 diff --git a/tests/functional/i/invalid/invalid_repr_returned.py b/tests/functional/i/invalid/invalid_repr_returned.py index afcc217a8d3..360308a93a5 100644 --- a/tests/functional/i/invalid/invalid_repr_returned.py +++ b/tests/functional/i/invalid/invalid_repr_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/invalid/invalid_str_returned.py b/tests/functional/i/invalid/invalid_str_returned.py index d02aef148f6..59d14fbb99e 100644 --- a/tests/functional/i/invalid/invalid_str_returned.py +++ b/tests/functional/i/invalid/invalid_str_returned.py @@ -2,7 +2,6 @@ # pylint: disable=too-few-public-methods,missing-docstring,import-error,unnecessary-lambda-assignment import six - from missing import Missing diff --git a/tests/functional/i/isinstance_second_argument.py b/tests/functional/i/isinstance_second_argument.py index cf32cbfbb55..5e5fde83e25 100644 --- a/tests/functional/i/isinstance_second_argument.py +++ b/tests/functional/i/isinstance_second_argument.py @@ -1,8 +1,10 @@ #pylint: disable=missing-docstring, undefined-variable, invalid-name, too-few-public-methods, wrong-import-position,import-error import collections + from unknown import Unknown + # Positive test cases class A: pass diff --git a/tests/functional/i/iterable_context.py b/tests/functional/i/iterable_context.py index fb035c4df28..c449088116b 100644 --- a/tests/functional/i/iterable_context.py +++ b/tests/functional/i/iterable_context.py @@ -120,6 +120,7 @@ def test(*args): # skip uninferable instances from some_missing_module import Iterable + class MyClass(Iterable): pass diff --git a/tests/functional/i/iterable_context_py36.py b/tests/functional/i/iterable_context_py36.py index d50d3da981b..993add5f5a7 100644 --- a/tests/functional/i/iterable_context_py36.py +++ b/tests/functional/i/iterable_context_py36.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring,too-few-public-methods,unused-variable,unnecessary-comprehension import asyncio + class AIter: async def __aiter__(self): for value in range(20): diff --git a/tests/functional/l/logging/logging_format_interpolation.py b/tests/functional/l/logging/logging_format_interpolation.py index e9896619212..ff00d2fe476 100644 --- a/tests/functional/l/logging/logging_format_interpolation.py +++ b/tests/functional/l/logging/logging_format_interpolation.py @@ -8,6 +8,7 @@ # Muck up the names in an effort to confuse... import logging as renamed_logging import os as logging + from uninferable import UNINFERABLE FORMAT_STR = '{0}, {1}' diff --git a/tests/functional/l/logging/logging_format_interpolation_py36.py b/tests/functional/l/logging/logging_format_interpolation_py36.py index 2601c5bfce2..0cee7a116ba 100644 --- a/tests/functional/l/logging/logging_format_interpolation_py36.py +++ b/tests/functional/l/logging/logging_format_interpolation_py36.py @@ -1,5 +1,4 @@ """Test logging-fstring-interpolation for Python 3.6""" import logging as renamed_logging - renamed_logging.info(f'Read {renamed_logging} from globals') # [logging-fstring-interpolation] diff --git a/tests/functional/l/logging/logging_fstring_interpolation_py36.py b/tests/functional/l/logging/logging_fstring_interpolation_py36.py index 5aebb7dd26d..fa8dd9ce7f7 100644 --- a/tests/functional/l/logging/logging_fstring_interpolation_py36.py +++ b/tests/functional/l/logging/logging_fstring_interpolation_py36.py @@ -1,10 +1,8 @@ """Test logging-fstring-interpolation for Python 3.6""" # pylint: disable=invalid-name -from datetime import datetime - import logging as renamed_logging - +from datetime import datetime local_var_1 = 4 local_var_2 = "run!" diff --git a/tests/functional/l/logging/logging_not_lazy_with_logger.py b/tests/functional/l/logging/logging_not_lazy_with_logger.py index ad94d32e106..3d8927e4a8e 100644 --- a/tests/functional/l/logging/logging_not_lazy_with_logger.py +++ b/tests/functional/l/logging/logging_not_lazy_with_logger.py @@ -1,8 +1,8 @@ """Logging warnings using a logger class.""" # pylint: disable=consider-using-f-string from __future__ import absolute_import -import logging +import logging LOG = logging.getLogger("domain") LOG.debug("%s" % "junk") # [logging-not-lazy] diff --git a/tests/functional/m/mapping_context.py b/tests/functional/m/mapping_context.py index 8dc6b3b72d8..9124794062d 100644 --- a/tests/functional/m/mapping_context.py +++ b/tests/functional/m/mapping_context.py @@ -90,6 +90,7 @@ def dispatch(self): # skip uninferable instances from some_missing_module import Mapping + class MyClass(Mapping): pass diff --git a/tests/functional/m/member/member_checks.py b/tests/functional/m/member/member_checks.py index ff109d659a6..bcc778e69a6 100644 --- a/tests/functional/m/member/member_checks.py +++ b/tests/functional/m/member/member_checks.py @@ -219,6 +219,8 @@ def __init__(self, flag): self.attribute.append(1) from enum import Enum + + class Animal(Enum): ANT = 1 BEE = 2 diff --git a/tests/functional/m/member/member_checks_py37.py b/tests/functional/m/member/member_checks_py37.py index ebbedbde36f..cc354ec60a7 100644 --- a/tests/functional/m/member/member_checks_py37.py +++ b/tests/functional/m/member/member_checks_py37.py @@ -1,6 +1,6 @@ # pylint: disable=missing-docstring -import collections.abc import asyncio +import collections.abc isinstance([], collections.abc.Iterable) diff --git a/tests/functional/m/membership_protocol.py b/tests/functional/m/membership_protocol.py index 10bec9603e5..ecd440cd5a5 100644 --- a/tests/functional/m/membership_protocol.py +++ b/tests/functional/m/membership_protocol.py @@ -54,6 +54,7 @@ def __getitem__(self, key): # do not emit warning if class has unknown bases from some_missing_module import ImportedClass + class MaybeIterable(ImportedClass): pass diff --git a/tests/functional/m/misplaced_future.py b/tests/functional/m/misplaced_future.py index b4317d96f46..ddffb3c7303 100644 --- a/tests/functional/m/misplaced_future.py +++ b/tests/functional/m/misplaced_future.py @@ -1,6 +1,7 @@ """Test that __future__ is not the first statement after the docstring.""" -import collections -from __future__ import print_function # [misplaced-future] +from __future__ import print_function # [misplaced-future] from __future__ import with_statement +import collections + DATA = collections diff --git a/tests/functional/m/missing/missing_final_newline.py b/tests/functional/m/missing/missing_final_newline.py index 370f902b75c..04678bf9588 100644 --- a/tests/functional/m/missing/missing_final_newline.py +++ b/tests/functional/m/missing/missing_final_newline.py @@ -1,4 +1,5 @@ """This file does not have a final newline.""" from __future__ import print_function + # +1:[missing-final-newline] -print(1) \ No newline at end of file +print(1) diff --git a/tests/functional/m/missing/missing_timeout.py b/tests/functional/m/missing/missing_timeout.py index 13ff35f862a..97dd7b7a2a3 100644 --- a/tests/functional/m/missing/missing_timeout.py +++ b/tests/functional/m/missing/missing_timeout.py @@ -3,24 +3,22 @@ # pylint: disable=consider-using-with,import-error,no-member,no-name-in-module,reimported import requests -from requests import ( - delete, - delete as delete_r, - get, - get as get_r, - head, - head as head_r, - options, - options as options_r, - patch, - patch as patch_r, - post, - post as post_r, - put, - put as put_r, - request, - request as request_r, -) +from requests import delete +from requests import delete as delete_r +from requests import get +from requests import get as get_r +from requests import head +from requests import head as head_r +from requests import options +from requests import options as options_r +from requests import patch +from requests import patch as patch_r +from requests import post +from requests import post as post_r +from requests import put +from requests import put as put_r +from requests import request +from requests import request as request_r # requests without timeout requests.delete("http://localhost") # [missing-timeout] diff --git a/tests/functional/m/multiple_imports.py b/tests/functional/m/multiple_imports.py index 9008dcc529c..01465e0498c 100644 --- a/tests/functional/m/multiple_imports.py +++ b/tests/functional/m/multiple_imports.py @@ -1,2 +1,3 @@ # pylint: disable=missing-docstring, unused-import -import os, socket # [multiple-imports] +import os # [multiple-imports] +import socket diff --git a/tests/functional/n/name/name_final.py b/tests/functional/n/name/name_final.py index 60b92ce1800..0b2eea919e0 100644 --- a/tests/functional/n/name/name_final.py +++ b/tests/functional/n/name/name_final.py @@ -3,6 +3,7 @@ import typing from typing import Final + class Foo: """Class with class constants annotated with Final.""" CLASS_CONST: Final[int] = 42 diff --git a/tests/functional/n/name/name_final_snake_case.py b/tests/functional/n/name/name_final_snake_case.py index ddfc3537a69..3301cc914e6 100644 --- a/tests/functional/n/name/name_final_snake_case.py +++ b/tests/functional/n/name/name_final_snake_case.py @@ -3,6 +3,7 @@ import typing from typing import Final + class Foo: """Class with class constants annotated with Final.""" CLASS_CONST: Final[int] = 42 # [invalid-name] diff --git a/tests/functional/n/namedtuple_member_inference.py b/tests/functional/n/namedtuple_member_inference.py index 09dc6dd445c..3a4487ef1d3 100644 --- a/tests/functional/n/namedtuple_member_inference.py +++ b/tests/functional/n/namedtuple_member_inference.py @@ -5,7 +5,6 @@ """ from collections import namedtuple - Thing = namedtuple('Thing', ()) Fantastic = namedtuple('Fantastic', ['foo']) diff --git a/tests/functional/n/names_in__all__.py b/tests/functional/n/names_in__all__.py index 38ed18a2e78..75cf791e72c 100644 --- a/tests/functional/n/names_in__all__.py +++ b/tests/functional/n/names_in__all__.py @@ -7,8 +7,9 @@ * This module imports path and republished it in __all__. No errors are expected. """ -from os import path from collections import deque +from os import path + from missing import Missing __all__ = [ diff --git a/tests/functional/n/no/no_member.py b/tests/functional/n/no/no_member.py index 1db70cde540..5a17500fefe 100644 --- a/tests/functional/n/no/no_member.py +++ b/tests/functional/n/no/no_member.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring, unused-argument, wrong-import-position, invalid-name from pathlib import Path + # Regression test for https://github.com/PyCQA/pylint/issues/400 class TestListener: def __init__(self): diff --git a/tests/functional/n/no/no_member_nested_namedtuple.py b/tests/functional/n/no/no_member_nested_namedtuple.py index 6a87ff63d75..57a4c0f8983 100644 --- a/tests/functional/n/no/no_member_nested_namedtuple.py +++ b/tests/functional/n/no/no_member_nested_namedtuple.py @@ -1,5 +1,6 @@ from typing import NamedTuple + class Ax(NamedTuple): class Bx: b = 0 diff --git a/tests/functional/n/no/no_member_subclassed_dataclasses.py b/tests/functional/n/no/no_member_subclassed_dataclasses.py index 918abc5dbca..0ea26108f1d 100644 --- a/tests/functional/n/no/no_member_subclassed_dataclasses.py +++ b/tests/functional/n/no/no_member_subclassed_dataclasses.py @@ -1,7 +1,8 @@ -from abc import ABCMeta, abstractmethod import dataclasses as dc +from abc import ABCMeta, abstractmethod from typing import Any, Dict + @dc.dataclass(frozen=True) class DeploymentState(metaclass=ABCMeta): type: str diff --git a/tests/functional/n/no/no_name_in_module.py b/tests/functional/n/no/no_name_in_module.py index 26c0079b6e8..1a83d699fd9 100644 --- a/tests/functional/n/no/no_name_in_module.py +++ b/tests/functional/n/no/no_name_in_module.py @@ -4,25 +4,30 @@ import collections.tutu # [no-name-in-module] from collections import toto # [no-name-in-module] + toto.yo() from xml.etree import ElementTree + ElementTree.nonexistant_function() # [no-member] ElementTree.another.nonexistant.function() # [no-member] import sys + print(sys.stdout, 'hello world') print(sys.stdoout, 'bye bye world') # [no-member] import re + re.finditer('*', 'yo') +import os +from re import compiile, findiiter # [no-name-in-module,no-name-in-module] + from rie import * -from re import findiiter, compiile # [no-name-in-module,no-name-in-module] -import os 'SOMEVAR' in os.environ # [pointless-statement] try: @@ -31,7 +36,7 @@ something = None try: - from collections import anything # [no-name-in-module] + from collections import anything # [no-name-in-module] except ValueError: anything = None @@ -46,12 +51,12 @@ pass try: - import collections.indeed_missing # [no-name-in-module] + import collections.indeed_missing # [no-name-in-module] except ValueError: pass try: - import collections.emit # [no-name-in-module] + import collections.emit # [no-name-in-module] except Exception: pass @@ -68,19 +73,18 @@ try: if something: - import collections.emit2 # [no-name-in-module] + import collections.emit2 # [no-name-in-module] except Exception: pass -from .no_self_argument import NoSelfArgument -from .no_self_argument import lala # [no-name-in-module] -from .no_self_argument.bla import lala1 # [no-name-in-module] - # Check ignored-modules setting from argparse import THIS_does_not_EXIST - # This captures the original failure in https://github.com/PyCQA/pylint/issues/6497 # only if numpy is installed. We are not installing numpy on CI (for now) from numpy.distutils.misc_util import is_sequence from pydantic import BaseModel + +from .no_self_argument import lala # [no-name-in-module] +from .no_self_argument import NoSelfArgument +from .no_self_argument.bla import lala1 # [no-name-in-module] diff --git a/tests/functional/n/non/non_init_parent_called.py b/tests/functional/n/non/non_init_parent_called.py index 7a6c94eadd7..c09482cfb4f 100644 --- a/tests/functional/n/non/non_init_parent_called.py +++ b/tests/functional/n/non/non_init_parent_called.py @@ -2,9 +2,10 @@ # pylint: disable=wrong-import-order, unnecessary-dunder-call """test for call to __init__ from a non ancestor class """ -from . import non_init_parent_called import nonexistant # [import-error] +from . import non_init_parent_called + class AAAA: """ancestor 1""" diff --git a/tests/functional/n/non_ascii_import/non_ascii_import.py b/tests/functional/n/non_ascii_import/non_ascii_import.py index 76163b28629..4d02736fddc 100644 --- a/tests/functional/n/non_ascii_import/non_ascii_import.py +++ b/tests/functional/n/non_ascii_import/non_ascii_import.py @@ -1,13 +1,14 @@ """Test that invalid module name imports causes correct error""" # pylint: disable=import-error, wrong-import-position, unused-wildcard-import, wildcard-import, wrong-import-order -import sys import os +import sys # allow module imports to test that this is indeed a valid python file SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.dirname(SCRIPT_DIR)) +from pathlib import * # test that star imports work correctly and give no error + import non_ascii_name_loł as ok -from pathlib import * # test that star imports work correctly and give no error print(ok) diff --git a/tests/functional/n/non_ascii_import/non_ascii_import_as_bad.py b/tests/functional/n/non_ascii_import/non_ascii_import_as_bad.py index df392961f41..0826405d036 100644 --- a/tests/functional/n/non_ascii_import/non_ascii_import_as_bad.py +++ b/tests/functional/n/non_ascii_import/non_ascii_import_as_bad.py @@ -1,6 +1,5 @@ """import non ascii alias""" import os.path as łos # [non-ascii-module-import] - # Usage should not raise a second error foo = łos.join("a", "b") diff --git a/tests/functional/n/non_ascii_import/non_ascii_import_as_okay.py b/tests/functional/n/non_ascii_import/non_ascii_import_as_okay.py index 35f8513fa9c..96eef37f085 100644 --- a/tests/functional/n/non_ascii_import/non_ascii_import_as_okay.py +++ b/tests/functional/n/non_ascii_import/non_ascii_import_as_okay.py @@ -1,7 +1,7 @@ """Test that invalid module name do not cause errors when using an alias""" # pylint: disable=import-error, wrong-import-position -import sys import os +import sys # allow module imports to test that this is indeed a valid python file SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/tests/functional/n/non_ascii_import/non_ascii_import_from_as.py b/tests/functional/n/non_ascii_import/non_ascii_import_from_as.py index 68beba0ec6f..7abb36c8dd9 100644 --- a/tests/functional/n/non_ascii_import/non_ascii_import_from_as.py +++ b/tests/functional/n/non_ascii_import/non_ascii_import_from_as.py @@ -1,6 +1,5 @@ """import as non ascii alias""" from os.path import join as łos # [non-ascii-module-import] - # Usage should not raise a second error foo = łos("a", "b") diff --git a/tests/functional/n/non_ascii_name/non_ascii_name_inline_var.py b/tests/functional/n/non_ascii_name/non_ascii_name_inline_var.py index 2d47e58c2d1..c03e60d3287 100644 --- a/tests/functional/n/non_ascii_name/non_ascii_name_inline_var.py +++ b/tests/functional/n/non_ascii_name/non_ascii_name_inline_var.py @@ -1,7 +1,6 @@ """inline loop non ascii variable definition""" import os - foo = [ f"{łol} " for łol in os.listdir(".") # [non-ascii-name] diff --git a/tests/functional/n/not_context_manager.py b/tests/functional/n/not_context_manager.py index b7d0c5a7a2a..187bd3acaf0 100644 --- a/tests/functional/n/not_context_manager.py +++ b/tests/functional/n/not_context_manager.py @@ -25,6 +25,8 @@ class NotAManager: # Tests contextlib.contextmanager usage is recognized as correct. from contextlib import contextmanager + + @contextmanager def dec(): yield @@ -41,6 +43,7 @@ def dec(): # Tests no messages about context manager protocol # if the type can't be inferred. from missing import Missing + with Missing(): pass diff --git a/tests/functional/o/overridden_final_method_py38.py b/tests/functional/o/overridden_final_method_py38.py index 252ea3c012b..2c6ad2df0b3 100644 --- a/tests/functional/o/overridden_final_method_py38.py +++ b/tests/functional/o/overridden_final_method_py38.py @@ -5,6 +5,7 @@ from typing import final + class Base: @final def my_method(self): diff --git a/tests/functional/p/postponed_evaluation_pep585.py b/tests/functional/p/postponed_evaluation_pep585.py index 9537fccefde..8d7ea0179bf 100644 --- a/tests/functional/p/postponed_evaluation_pep585.py +++ b/tests/functional/p/postponed_evaluation_pep585.py @@ -5,12 +5,12 @@ """ # pylint: disable=missing-docstring,unused-argument,unused-import,too-few-public-methods,invalid-name,inherit-non-class,unsupported-binary-operation,wrong-import-position,ungrouped-imports,unused-variable,unnecessary-direct-lambda-call from __future__ import annotations + import collections import dataclasses import typing from dataclasses import dataclass -from typing import Any, Dict, NamedTuple, TypedDict, Union, Tuple - +from typing import Any, Dict, NamedTuple, Tuple, TypedDict, Union AliasInvalid = list[int] # [unsubscriptable-object] @@ -105,6 +105,7 @@ def func2() -> list[int]: import contextlib import re + class OrderedDict: pass diff --git a/tests/functional/p/postponed_evaluation_pep585_error.py b/tests/functional/p/postponed_evaluation_pep585_error.py index 7c117e33e48..20250f737d3 100644 --- a/tests/functional/p/postponed_evaluation_pep585_error.py +++ b/tests/functional/p/postponed_evaluation_pep585_error.py @@ -10,7 +10,6 @@ from dataclasses import dataclass from typing import Any, Dict, NamedTuple, TypedDict, Union - AliasInvalid = list[int] # [unsubscriptable-object] class CustomIntList(typing.List[int]): diff --git a/tests/functional/p/postponed_evaluation_pep585_py39.py b/tests/functional/p/postponed_evaluation_pep585_py39.py index 5354e081fdf..dca6b710200 100644 --- a/tests/functional/p/postponed_evaluation_pep585_py39.py +++ b/tests/functional/p/postponed_evaluation_pep585_py39.py @@ -4,8 +4,7 @@ import dataclasses import typing from dataclasses import dataclass -from typing import Any, Dict, NamedTuple, TypedDict, Union, Tuple - +from typing import Any, Dict, NamedTuple, Tuple, TypedDict, Union AliasValid = list[int] @@ -100,6 +99,7 @@ def func2() -> list[int]: import contextlib import re + class OrderedDict: pass diff --git a/tests/functional/r/raising/raising_non_exception.py b/tests/functional/r/raising/raising_non_exception.py index e3040cdf497..9e24ce0a954 100644 --- a/tests/functional/r/raising/raising_non_exception.py +++ b/tests/functional/r/raising/raising_non_exception.py @@ -7,6 +7,7 @@ from missing_module import missing + class Exc: """Not an actual exception.""" diff --git a/tests/functional/r/redefined/redefined_builtin.py b/tests/functional/r/redefined/redefined_builtin.py index 9cb454dd09c..7aa332687f5 100644 --- a/tests/functional/r/redefined/redefined_builtin.py +++ b/tests/functional/r/redefined/redefined_builtin.py @@ -14,11 +14,12 @@ def function(): __doc__ = "reset the doc" +# Test default redefining-builtins-modules setting +from os import open + # Test redefining-builtins from notos import open # [redefined-builtin] -# Test default redefining-builtins-modules setting -from os import open # Test non-default redefining-builtins-modules setting in function def test(): diff --git a/tests/functional/r/redefined/redefined_outer_name_type_checking.py b/tests/functional/r/redefined/redefined_outer_name_type_checking.py index d452bcdb03f..b614ed29764 100644 --- a/tests/functional/r/redefined/redefined_outer_name_type_checking.py +++ b/tests/functional/r/redefined/redefined_outer_name_type_checking.py @@ -2,16 +2,15 @@ # pylint: disable=missing-function-docstring from __future__ import annotations -from typing import TYPE_CHECKING import typing as t +from typing import TYPE_CHECKING class Cls: def func(self, stuff: defaultdict, my_deque: deque): # These imports make the definition work. # pylint: disable=import-outside-toplevel - from collections import defaultdict - from collections import deque + from collections import defaultdict, deque obj = defaultdict() obj2 = deque() diff --git a/tests/functional/r/redundant_unittest_assert.py b/tests/functional/r/redundant_unittest_assert.py index b7efffc4ee4..8e798de75ef 100644 --- a/tests/functional/r/redundant_unittest_assert.py +++ b/tests/functional/r/redundant_unittest_assert.py @@ -8,6 +8,7 @@ import unittest + @unittest.skip("don't run this") class Tests(unittest.TestCase): def test_something(self): diff --git a/tests/functional/r/regression/regression_2306_enum_value.py b/tests/functional/r/regression/regression_2306_enum_value.py index 0cc23c2db78..41a1b8fdd1f 100644 --- a/tests/functional/r/regression/regression_2306_enum_value.py +++ b/tests/functional/r/regression/regression_2306_enum_value.py @@ -2,6 +2,7 @@ from enum import Enum + class Color(Enum): red = 1 green = 2 diff --git a/tests/functional/r/regression/regression_3535_double_enum_inherit.py b/tests/functional/r/regression/regression_3535_double_enum_inherit.py index 374b5f86065..cba4199e269 100644 --- a/tests/functional/r/regression/regression_3535_double_enum_inherit.py +++ b/tests/functional/r/regression/regression_3535_double_enum_inherit.py @@ -3,6 +3,7 @@ import enum + class A(enum.Enum): pass diff --git a/tests/functional/r/regression/regression_3595_notcallable_collections.py b/tests/functional/r/regression/regression_3595_notcallable_collections.py index 120b26a0483..139d5f0364f 100644 --- a/tests/functional/r/regression/regression_3595_notcallable_collections.py +++ b/tests/functional/r/regression/regression_3595_notcallable_collections.py @@ -3,6 +3,7 @@ import collections + class Example: def __init__(self): self.prev() diff --git a/tests/functional/r/regression/regression_4221_object_instanceattr.py b/tests/functional/r/regression/regression_4221_object_instanceattr.py index 4c346b1458f..666bebbc303 100644 --- a/tests/functional/r/regression/regression_4221_object_instanceattr.py +++ b/tests/functional/r/regression/regression_4221_object_instanceattr.py @@ -2,6 +2,7 @@ # https://github.com/PyCQA/pylint/issues/4221 import random + o = object() if random.choice([True, False]): o.count = None diff --git a/tests/functional/r/regression/regression_4358_unsubscriptable_enum.py b/tests/functional/r/regression/regression_4358_unsubscriptable_enum.py index 63a9d77499f..265cff194e9 100644 --- a/tests/functional/r/regression/regression_4358_unsubscriptable_enum.py +++ b/tests/functional/r/regression/regression_4358_unsubscriptable_enum.py @@ -3,6 +3,7 @@ from enum import Enum + class Foo(Enum): BAR = 1 diff --git a/tests/functional/r/regression/regression_4891.py b/tests/functional/r/regression/regression_4891.py index 34945e81268..8e5abab8e8f 100644 --- a/tests/functional/r/regression/regression_4891.py +++ b/tests/functional/r/regression/regression_4891.py @@ -2,6 +2,7 @@ # pylint: disable=too-few-public-methods import copy + class MyData: ''' class docstring diff --git a/tests/functional/r/regression_02/regression_4660.py b/tests/functional/r/regression_02/regression_4660.py index 872ed6ca280..330cc7cdb41 100644 --- a/tests/functional/r/regression_02/regression_4660.py +++ b/tests/functional/r/regression_02/regression_4660.py @@ -5,8 +5,8 @@ from __future__ import annotations -from typing import Union, Any, Literal, overload from collections.abc import Callable +from typing import Any, Literal, Union, overload def my_print(*args: Any) -> None: diff --git a/tests/functional/r/regression_02/regression_5030.py b/tests/functional/r/regression_02/regression_5030.py index 8aa22f8792a..fdf78c4771d 100644 --- a/tests/functional/r/regression_02/regression_5030.py +++ b/tests/functional/r/regression_02/regression_5030.py @@ -1,9 +1,9 @@ """Regression in astroid on ClassDef inference with two test cases. Fixed in https://github.com/PyCQA/astroid/pull/1181""" -from typing import Tuple, Type -from typing import Dict, List, Any from dataclasses import dataclass, field +from typing import Any, Dict, List, Tuple, Type + # https://github.com/PyCQA/pylint/issues/5030 def is_type_list(f_type: Type) -> bool: diff --git a/tests/functional/r/regression_02/regression_5801.py b/tests/functional/r/regression_02/regression_5801.py index 8c08ec6750d..756f18cbbe1 100644 --- a/tests/functional/r/regression_02/regression_5801.py +++ b/tests/functional/r/regression_02/regression_5801.py @@ -2,4 +2,5 @@ # pylint: disable=missing-docstring import struct + struct.unpack('h', b'\x00\x01') diff --git a/tests/functional/r/regression_02/regression_distutil_import_error_73.py b/tests/functional/r/regression_02/regression_distutil_import_error_73.py index d40c0973fe6..a73d5340108 100644 --- a/tests/functional/r/regression_02/regression_distutil_import_error_73.py +++ b/tests/functional/r/regression_02/regression_distutil_import_error_73.py @@ -10,6 +10,6 @@ # pylint: disable=unused-import, deprecated-module import distutils.version +from distutils import doesnottexists # [no-name-in-module] +from distutils.doesnottexists import nope # [no-name-in-module, import-error] from distutils.util import strtobool -from distutils import doesnottexists # [no-name-in-module] -from distutils.doesnottexists import nope # [no-name-in-module, import-error] diff --git a/tests/functional/r/regression_02/regression_enum_1734.py b/tests/functional/r/regression_02/regression_enum_1734.py index 06759c7d3dd..375a387de19 100644 --- a/tests/functional/r/regression_02/regression_enum_1734.py +++ b/tests/functional/r/regression_02/regression_enum_1734.py @@ -6,6 +6,7 @@ from enum import Enum + class Test(Enum): LOADED = "loaded", True SETUP_ERROR = "setup_error", True diff --git a/tests/functional/r/reimport.py b/tests/functional/r/reimport.py index 86f273d3b80..11d73bf9966 100644 --- a/tests/functional/r/reimport.py +++ b/tests/functional/r/reimport.py @@ -2,10 +2,9 @@ """ # pylint: disable=using-constant-test,ungrouped-imports,wrong-import-position,import-outside-toplevel -import os -from os.path import join, exists import os # [reimported] import re as _re +from os.path import exists, join __revision__ = 0 _re.match('yo', '.*') diff --git a/tests/functional/r/reimported.py b/tests/functional/r/reimported.py index 5584ff039c2..c7ca1219cd8 100644 --- a/tests/functional/r/reimported.py +++ b/tests/functional/r/reimported.py @@ -1,33 +1,24 @@ # pylint: disable=missing-docstring,unused-import,import-error, wildcard-import,unused-wildcard-import,redefined-builtin,no-name-in-module,ungrouped-imports,wrong-import-order -from time import sleep, sleep # [reimported] -from lala import missing, missing # [reimported] - -import missing1 -import missing1 # [reimported] - -from collections import deque -from itertools import deque # [reimported] - -from collections import OrderedDict +import email.encoders # [reimported] +import sys # [reimported] #pylint: disable=ungrouped-imports,wrong-import-order +import xml.etree.ElementTree +from collections import OrderedDict, deque +from email import encoders from itertools import OrderedDict as NotOrderedDict - from itertools import * +from itertools import deque # [reimported] from os import * - -import sys - -import xml.etree.ElementTree +from time import sleep # [reimported] from xml.etree import ElementTree # [reimported] -from email import encoders -import email.encoders # [reimported] +import missing1 # [reimported] +from lala import missing # [reimported] -import sys # [reimported] #pylint: disable=ungrouped-imports,wrong-import-order def no_reimport(): """docstring""" - import os #pylint: disable=import-outside-toplevel + import os # pylint: disable=import-outside-toplevel print(os) diff --git a/tests/functional/r/renamed_import_logging_not_lazy.py b/tests/functional/r/renamed_import_logging_not_lazy.py index 5eb23bf95a8..e807fc631d8 100644 --- a/tests/functional/r/renamed_import_logging_not_lazy.py +++ b/tests/functional/r/renamed_import_logging_not_lazy.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring, too-few-public-methods, no-member, consider-using-f-string from __future__ import absolute_import + # Muck up the names in an effort to confuse... import logging as renamed_logging diff --git a/tests/functional/s/shallow_copy_environ.py b/tests/functional/s/shallow_copy_environ.py index ee931d71a34..5a032c50a61 100644 --- a/tests/functional/s/shallow_copy_environ.py +++ b/tests/functional/s/shallow_copy_environ.py @@ -10,14 +10,15 @@ test_dict = {} copy.copy(test_dict) +import os as o # Test with renaming the functions from copy import copy as test_cp -import os as o test_cp(o.environ) # [shallow-copy-environ] # Regression test for non inferable objects import copy + from missing_library import MissingObject copy.copy(MissingObject) diff --git a/tests/functional/s/slots_checks.py b/tests/functional/s/slots_checks.py index 2c22e968ed6..b9b65915b88 100644 --- a/tests/functional/s/slots_checks.py +++ b/tests/functional/s/slots_checks.py @@ -4,6 +4,7 @@ # pylint: disable=using-constant-test, wrong-import-position, no-else-return, line-too-long, unused-private-member from collections import deque + def func(): if True: return ("a", "b", "c") diff --git a/tests/functional/s/socketerror_import.py b/tests/functional/s/socketerror_import.py index f9403d96669..9ea52683e74 100644 --- a/tests/functional/s/socketerror_import.py +++ b/tests/functional/s/socketerror_import.py @@ -2,5 +2,4 @@ from socket import error - print(error) diff --git a/tests/functional/s/stop_iteration_inside_generator.py b/tests/functional/s/stop_iteration_inside_generator.py index a143fd946c0..69fc814b7dd 100644 --- a/tests/functional/s/stop_iteration_inside_generator.py +++ b/tests/functional/s/stop_iteration_inside_generator.py @@ -5,6 +5,7 @@ # pylint: disable=not-callable,raise-missing-from,broad-exception-raised import asyncio + class RebornStopIteration(StopIteration): """ A class inheriting from StopIteration exception @@ -112,6 +113,7 @@ def gen_next_with_sentinel(): from itertools import count, cycle + # https://github.com/PyCQA/pylint/issues/2158 def generator_using_next(): counter = count() diff --git a/tests/functional/s/string/string_formatting.py b/tests/functional/s/string/string_formatting.py index cb88680e1a6..5fdb2893d9d 100644 --- a/tests/functional/s/string/string_formatting.py +++ b/tests/functional/s/string/string_formatting.py @@ -2,9 +2,10 @@ # pylint: disable=too-few-public-methods, import-error, unused-argument, line-too-long, # pylint: disable=consider-using-f-string +import logging import os import sys -import logging + from missing import Missing @@ -156,7 +157,8 @@ def issue338(): trying to infer EmptyNodes (resulted after mocking the members of namedtuples). """ - from collections import namedtuple # pylint: disable=import-outside-toplevel + from collections import \ + namedtuple # pylint: disable=import-outside-toplevel class Crash(namedtuple("C", "foo bar")): """ Looking for attributes in __str__ will crash, diff --git a/tests/functional/s/string/string_formatting_failed_inference.py b/tests/functional/s/string/string_formatting_failed_inference.py index e47ca5baaee..d56e4fd7f6e 100644 --- a/tests/functional/s/string/string_formatting_failed_inference.py +++ b/tests/functional/s/string/string_formatting_failed_inference.py @@ -1,4 +1,5 @@ """ Testing string format with a failed inference. This should not crash. """ # pylint: disable=using-constant-test, consider-using-f-string import collections + "{dict[0]}".format(dict=collections.defaultdict(int)) diff --git a/tests/functional/s/string/string_formatting_failed_inference_py35.py b/tests/functional/s/string/string_formatting_failed_inference_py35.py index f4d3ef34ea5..461dbaa4993 100644 --- a/tests/functional/s/string/string_formatting_failed_inference_py35.py +++ b/tests/functional/s/string/string_formatting_failed_inference_py35.py @@ -1,6 +1,7 @@ """ Testing string format with a failed inference. This should not crash. """ # pylint: disable=using-constant-test, consider-using-f-string import collections + "{dict[0]}".format(dict=collections.defaultdict(int)) COMMENT = "message %s %s %s" % (0, *(1 if "cond" else 2,) * 2) diff --git a/tests/functional/s/string/string_formatting_py3.py b/tests/functional/s/string/string_formatting_py3.py index 6ab4d8c915c..de1229dd030 100644 --- a/tests/functional/s/string/string_formatting_py3.py +++ b/tests/functional/s/string/string_formatting_py3.py @@ -17,5 +17,5 @@ def issue_957_bad2(): def issue_957_uninferable(): - from butchery import meat # pylint: disable=import-outside-toplevel + from butchery import meat # pylint: disable=import-outside-toplevel print('%s%s%s' % ('eggs', *meat)) diff --git a/tests/functional/s/subprocess_popen_preexec_fn.py b/tests/functional/s/subprocess_popen_preexec_fn.py index 722612442b2..a219a8ed898 100644 --- a/tests/functional/s/subprocess_popen_preexec_fn.py +++ b/tests/functional/s/subprocess_popen_preexec_fn.py @@ -2,6 +2,7 @@ import subprocess + def foo(): pass diff --git a/tests/functional/s/subprocess_run_check.py b/tests/functional/s/subprocess_run_check.py index fc4d99d9bf9..580f8e9044f 100644 --- a/tests/functional/s/subprocess_run_check.py +++ b/tests/functional/s/subprocess_run_check.py @@ -2,5 +2,4 @@ import subprocess - subprocess.run() # [subprocess-run-check] diff --git a/tests/functional/s/super/super_checks.py b/tests/functional/s/super/super_checks.py index 050fd3c81fa..b7fd820ffac 100644 --- a/tests/functional/s/super/super_checks.py +++ b/tests/functional/s/super/super_checks.py @@ -3,6 +3,7 @@ # pylint: disable=super-with-arguments from unknown import Missing + class Aaaa: """old style""" def hop(self): diff --git a/tests/functional/s/superfluous_parens.py b/tests/functional/s/superfluous_parens.py index 35acfd5d31d..848e22edd36 100644 --- a/tests/functional/s/superfluous_parens.py +++ b/tests/functional/s/superfluous_parens.py @@ -2,6 +2,7 @@ # pylint: disable=unneeded-not, unnecessary-comprehension, missing-function-docstring, invalid-name, fixme # pylint: disable=import-error, missing-class-docstring, too-few-public-methods import numpy as np + A = 3 if (A == 5): # [superfluous-parens] pass diff --git a/tests/functional/s/sys_stream_regression_1004.py b/tests/functional/s/sys_stream_regression_1004.py index c0391859dbf..e87cbaa0899 100644 --- a/tests/functional/s/sys_stream_regression_1004.py +++ b/tests/functional/s/sys_stream_regression_1004.py @@ -2,6 +2,7 @@ # pylint: disable=missing-docstring, pointless-statement import sys + sys.__stdout__.buffer.write('test') sys.__stdout__.buff # [no-member] sys.__stdout__.buffer.write1 # [no-member] diff --git a/tests/functional/t/ternary.py b/tests/functional/t/ternary.py index 48f97ffd97e..2423741fcdf 100644 --- a/tests/functional/t/ternary.py +++ b/tests/functional/t/ternary.py @@ -1,5 +1,6 @@ """Test for old ternary constructs""" -from UNINFERABLE import condition, some_callable, maybe_true, maybe_false # pylint: disable=import-error +from UNINFERABLE import (condition, # pylint: disable=import-error + maybe_false, maybe_true, some_callable) TRUE_VALUE = True FALSE_VALUE = False diff --git a/tests/functional/t/too/too_few_public_methods_excluded.py b/tests/functional/t/too/too_few_public_methods_excluded.py index 2ee8f1c4a48..785a2d9b414 100644 --- a/tests/functional/t/too/too_few_public_methods_excluded.py +++ b/tests/functional/t/too/too_few_public_methods_excluded.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring from json import JSONEncoder + class Control: # [too-few-public-methods] ... diff --git a/tests/functional/t/too/too_many_ancestors.py b/tests/functional/t/too/too_many_ancestors.py index a460e4f16ed..3cf323a63fc 100644 --- a/tests/functional/t/too/too_many_ancestors.py +++ b/tests/functional/t/too/too_many_ancestors.py @@ -1,6 +1,7 @@ # pylint: disable=missing-docstring, too-few-public-methods, arguments-differ from collections.abc import MutableSequence + class Aaaa: pass class Bbbb: diff --git a/tests/functional/t/too/too_many_instance_attributes_py37.py b/tests/functional/t/too/too_many_instance_attributes_py37.py index 68e101892ab..a0450b92a2f 100644 --- a/tests/functional/t/too/too_many_instance_attributes_py37.py +++ b/tests/functional/t/too/too_many_instance_attributes_py37.py @@ -1,5 +1,6 @@ # pylint: disable=missing-docstring, too-few-public-methods -from dataclasses import dataclass, InitVar +from dataclasses import InitVar, dataclass + # InitVars should not count as instance attributes (see issue #3754) # Default max_instance_attributes is 7 diff --git a/tests/functional/t/typing_use.py b/tests/functional/t/typing_use.py index b92a0872247..59895e4c5a5 100644 --- a/tests/functional/t/typing_use.py +++ b/tests/functional/t/typing_use.py @@ -3,6 +3,7 @@ import typing from typing import overload + @typing.overload def double_with_docstring(arg: str) -> str: """Return arg, concatenated with itself.""" diff --git a/tests/functional/u/unbalanced_tuple_unpacking.py b/tests/functional/u/unbalanced_tuple_unpacking.py index 22674893398..66665dface0 100644 --- a/tests/functional/u/unbalanced_tuple_unpacking.py +++ b/tests/functional/u/unbalanced_tuple_unpacking.py @@ -1,6 +1,8 @@ """Check possible unbalanced tuple unpacking """ from __future__ import absolute_import + from typing import NamedTuple + from functional.u.unpacking.unpacking import unpack # pylint: disable=missing-class-docstring, missing-function-docstring, using-constant-test, import-outside-toplevel diff --git a/tests/functional/u/undefined/undefined_variable.py b/tests/functional/u/undefined/undefined_variable.py index 78a32dacc46..155e1bf87c4 100644 --- a/tests/functional/u/undefined/undefined_variable.py +++ b/tests/functional/u/undefined/undefined_variable.py @@ -265,10 +265,7 @@ def func_should_fail(_dt: datetime): # [used-before-assignment] if TYPE_CHECKING: - from collections import Counter - from collections import OrderedDict - from collections import defaultdict - from collections import UserDict + from collections import Counter, OrderedDict, UserDict, defaultdict else: Counter = object OrderedDict = object diff --git a/tests/functional/u/undefined/undefined_variable_py30.py b/tests/functional/u/undefined/undefined_variable_py30.py index ff77aaf8e8e..046c89208b2 100644 --- a/tests/functional/u/undefined/undefined_variable_py30.py +++ b/tests/functional/u/undefined/undefined_variable_py30.py @@ -60,6 +60,7 @@ def test_bad2(self, **bac: trop2): # [undefined-variable] import abc from abc import ABCMeta + class Bad(metaclass=ABCMet): # [undefined-variable] """ Notice the typo """ diff --git a/tests/functional/u/ungrouped_imports.py b/tests/functional/u/ungrouped_imports.py index ace3a8e3f19..198da748c73 100644 --- a/tests/functional/u/ungrouped_imports.py +++ b/tests/functional/u/ungrouped_imports.py @@ -1,34 +1,37 @@ """Checks import order rule""" # pylint: disable=unused-import,wrong-import-position,wrong-import-order,using-constant-test # pylint: disable=import-error -import six +import logging # [ungrouped-imports] import logging.config import os.path -from astroid import are_exclusive -import logging # [ungrouped-imports] + +import six import unused_import +from astroid import are_exclusive + try: import os # [ungrouped-imports] except ImportError: pass -from os import pardir +from os import pardir, sep + import scipy -from os import sep -from astroid import exceptions # [ungrouped-imports] +from astroid import exceptions # [ungrouped-imports] + if True: import logging.handlers # [ungrouped-imports] -from os.path import join # [ungrouped-imports] + # Test related to compatibility with isort: # We check that we do not create error with the old way pylint was handling it import subprocess import unittest -from unittest import TestCase -from unittest.mock import MagicMock - - +from os.path import join # [ungrouped-imports] # https://github.com/PyCQA/pylint/issues/3382 # Imports in a `if TYPE_CHECKING` block should not trigger `ungrouped-imports` from typing import TYPE_CHECKING +from unittest import TestCase +from unittest.mock import MagicMock + if TYPE_CHECKING: import re from typing import List diff --git a/tests/functional/u/ungrouped_imports_suppression.py b/tests/functional/u/ungrouped_imports_suppression.py index 9b482b355a3..f335a976013 100644 --- a/tests/functional/u/ungrouped_imports_suppression.py +++ b/tests/functional/u/ungrouped_imports_suppression.py @@ -6,9 +6,12 @@ # pylint: disable=unused-import, wrong-import-order import logging.config -import os.path -from astroid import are_exclusive # pylint: disable=ungrouped-imports # [useless-suppression] import logging.handlers # pylint: disable=ungrouped-imports # This should not raise useless-suppression +import os.path + +from astroid import \ + are_exclusive # pylint: disable=ungrouped-imports # [useless-suppression] + try: import os # [ungrouped-imports] except ImportError: diff --git a/tests/functional/u/unnecessary/unnecessary_ellipsis.py b/tests/functional/u/unnecessary/unnecessary_ellipsis.py index c46fd323a06..7b43e4abf4d 100644 --- a/tests/functional/u/unnecessary/unnecessary_ellipsis.py +++ b/tests/functional/u/unnecessary/unnecessary_ellipsis.py @@ -2,7 +2,7 @@ # pylint: disable=missing-docstring, too-few-public-methods, invalid-name, unused-argument, comparison-of-constants -from typing import List, overload, Union +from typing import List, Union, overload # Ellipsis and preceding statement try: diff --git a/tests/functional/u/unpacking/unpacking_non_sequence.py b/tests/functional/u/unpacking/unpacking_non_sequence.py index feb465ecbec..e8fcaec24f8 100644 --- a/tests/functional/u/unpacking/unpacking_non_sequence.py +++ b/tests/functional/u/unpacking/unpacking_non_sequence.py @@ -3,9 +3,9 @@ # pylint: disable=too-few-public-methods, invalid-name, attribute-defined-outside-init, unused-variable # pylint: disable=using-constant-test, missing-docstring, wrong-import-order,wrong-import-position,no-else-return from os import rename as nonseq_func -from functional.u.unpacking.unpacking import nonseq from typing import NamedTuple +from functional.u.unpacking.unpacking import nonseq # Working diff --git a/tests/functional/u/unreachable.py b/tests/functional/u/unreachable.py index 0211a61366e..7e51ef4946f 100644 --- a/tests/functional/u/unreachable.py +++ b/tests/functional/u/unreachable.py @@ -5,6 +5,7 @@ import signal import sys + def func1(): return 1 print('unreachable') # [unreachable] diff --git a/tests/functional/u/unsubscriptable_value.py b/tests/functional/u/unsubscriptable_value.py index 79e17903b71..cdfbdca99e9 100644 --- a/tests/functional/u/unsubscriptable_value.py +++ b/tests/functional/u/unsubscriptable_value.py @@ -59,6 +59,7 @@ def powers_of_two(): # skip instances with unknown base classes from some_missing_module import LibSubscriptable + class MaybeSubscriptable(LibSubscriptable): pass @@ -85,6 +86,7 @@ def test(*args, **kwargs): # deque from collections import deque + deq = deque(maxlen=10) deq.append(42) deq[0] diff --git a/tests/functional/u/unsupported/unsupported_assignment_operation.py b/tests/functional/u/unsupported/unsupported_assignment_operation.py index 93e84c02069..261a88c90bb 100644 --- a/tests/functional/u/unsupported/unsupported_assignment_operation.py +++ b/tests/functional/u/unsupported/unsupported_assignment_operation.py @@ -57,6 +57,7 @@ def powers_of_two(): # skip instances with unknown base classes from some_missing_module import LibSubscriptable + class MaybeSubscriptable(LibSubscriptable): pass @@ -83,6 +84,7 @@ def test(*args, **kwargs): # deque from collections import deque + deq = deque(maxlen=10) deq.append(42) deq[0] = 42 diff --git a/tests/functional/u/unsupported/unsupported_binary_operation.py b/tests/functional/u/unsupported/unsupported_binary_operation.py index 00db8cdfe54..59478eaaffa 100644 --- a/tests/functional/u/unsupported/unsupported_binary_operation.py +++ b/tests/functional/u/unsupported/unsupported_binary_operation.py @@ -5,7 +5,6 @@ import collections - 1 + "a" # [unsupported-binary-operation] 1 - [] # [unsupported-binary-operation] 1 * {} # [unsupported-binary-operation] @@ -61,6 +60,8 @@ def __radd__(self, other): # Don't emit for this case since we don't know what unknown is. from unknown import Unknown + + class Base(Unknown): pass Base() * 23 diff --git a/tests/functional/u/unsupported/unsupported_delete_operation.py b/tests/functional/u/unsupported/unsupported_delete_operation.py index c33a6eb8918..eaee42e9402 100644 --- a/tests/functional/u/unsupported/unsupported_delete_operation.py +++ b/tests/functional/u/unsupported/unsupported_delete_operation.py @@ -57,6 +57,7 @@ def powers_of_two(): # skip instances with unknown base classes from some_missing_module import LibSubscriptable + class MaybeSubscriptable(LibSubscriptable): pass @@ -83,6 +84,7 @@ def test(*args, **kwargs): # deque from collections import deque + deq = deque(maxlen=10) deq.append(42) del deq[0] diff --git a/tests/functional/u/unused/unused_import.py b/tests/functional/u/unused/unused_import.py index 24300587d1f..d9bf379a35c 100644 --- a/tests/functional/u/unused/unused_import.py +++ b/tests/functional/u/unused/unused_import.py @@ -1,16 +1,16 @@ """unused import""" # pylint: disable=undefined-all-variable, import-error, too-few-public-methods, missing-docstring,wrong-import-position, multiple-imports +import html.parser +import os.path as test # [unused-import] +import re # [unused-import] import xml.etree # [unused-import] import xml.sax # [unused-import] -import os.path as test # [unused-import] from abc import ABCMeta +# +1:[unused-import,unused-import] +from collections import Counter, OrderedDict, deque from sys import argv as test2 # [unused-import] from sys import flags # [unused-import] -# +1:[unused-import,unused-import] -from collections import deque, OrderedDict, Counter -import re, html.parser # [unused-import] - DATA = Counter() # pylint: disable=self-assigning-variable from fake import SomeName, SomeOtherName # [unused-import] @@ -22,13 +22,12 @@ class SomeClass: SomeOtherName = SomeOtherName -from never import __all__ - # pylint: disable=wrong-import-order,ungrouped-imports,reimported import typing -from typing import TYPE_CHECKING import typing as t +from typing import TYPE_CHECKING +from never import __all__ if typing.TYPE_CHECKING: import collections @@ -78,8 +77,9 @@ def blop(self): from typing import NoReturn # Pathological cases -from io import TYPE_CHECKING # pylint: disable=no-name-in-module import trace as t +from io import TYPE_CHECKING # pylint: disable=no-name-in-module + import astroid as typing TYPE_CHECKING = "red herring" diff --git a/tests/functional/u/unused/unused_import_class_def_keyword.py b/tests/functional/u/unused/unused_import_class_def_keyword.py index 0d6b5998736..84e76364223 100644 --- a/tests/functional/u/unused/unused_import_class_def_keyword.py +++ b/tests/functional/u/unused/unused_import_class_def_keyword.py @@ -6,9 +6,7 @@ # pylint: disable=missing-docstring,too-few-public-methods,invalid-name,import-error # Imports don't exist! Only check `unused-import` -from const import DOMAIN -from const import DOMAIN_2 -from const import DOMAIN_3 +from const import DOMAIN, DOMAIN_2, DOMAIN_3 class Child: diff --git a/tests/functional/u/unused/unused_import_py30.py b/tests/functional/u/unused/unused_import_py30.py index 2e79b579563..e58c5ded3fa 100644 --- a/tests/functional/u/unused/unused_import_py30.py +++ b/tests/functional/u/unused/unused_import_py30.py @@ -3,8 +3,9 @@ import abc import sys -from abc import ABCMeta -from abc import ABCMeta as SomethingElse # [reimported] +from abc import ABCMeta # [reimported] +from abc import ABCMeta as SomethingElse + class Meta(metaclass=abc.ABCMeta): """ Test """ diff --git a/tests/functional/u/unused/unused_import_py39.py b/tests/functional/u/unused/unused_import_py39.py index 2a897b1741d..d969c568752 100644 --- a/tests/functional/u/unused/unused_import_py39.py +++ b/tests/functional/u/unused/unused_import_py39.py @@ -3,8 +3,7 @@ `typing.Annotated` was introduced in Python version 3.9 """ -from pathlib import Path # [unused-import] import typing as t - +from pathlib import Path # [unused-import] example: t.Annotated[str, "Path"] = "/foo/bar" diff --git a/tests/functional/u/unused/unused_name_from_wildcard_import.py b/tests/functional/u/unused/unused_name_from_wildcard_import.py index 54658b8550b..a1975d8d9fe 100644 --- a/tests/functional/u/unused/unused_name_from_wildcard_import.py +++ b/tests/functional/u/unused/unused_name_from_wildcard_import.py @@ -1,5 +1,5 @@ """check unused import from a wildcard import""" # pylint: disable=line-too-long from .unused_argument_py3 import * # [unused-wildcard-import, wildcard-import] -from .unused_global_variable1 import * # [unused-wildcard-import, wildcard-import] -from .unused_import_py30 import * # [unused-wildcard-import, wildcard-import] +from .unused_global_variable1 import * # [unused-wildcard-import, wildcard-import] +from .unused_import_py30 import * # [unused-wildcard-import, wildcard-import] diff --git a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py index 400e7725e04..bfa85355055 100644 --- a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py +++ b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py @@ -1,8 +1,8 @@ """Test if pylint sees names inside string literal type annotations. #3299""" # pylint: disable=too-few-public-methods -from argparse import ArgumentParser, Namespace import os +from argparse import ArgumentParser, Namespace from os import PathLike from pathlib import Path from typing import NoReturn, Set diff --git a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py310.py b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py310.py index 00bf5799fcb..157079ed49d 100644 --- a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py310.py +++ b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py310.py @@ -2,6 +2,7 @@ from typing import TypeAlias + def unused_variable_should_not_be_emitted(): """unused-variable shouldn't be emitted for Example.""" Example: TypeAlias = int diff --git a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py38.py b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py38.py index 96658ae369f..cdf7c46d719 100644 --- a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py38.py +++ b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py38.py @@ -1,10 +1,10 @@ # pylint: disable=missing-docstring -from argparse import ArgumentParser # [unused-import] -from argparse import Namespace # [unused-import] import http # [unused-import] -from http import HTTPStatus import typing as t +from argparse import ArgumentParser # [unused-import] +from argparse import Namespace # [unused-import] +from http import HTTPStatus from typing import Literal as Lit # str inside Literal shouldn't be treated as names diff --git a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py index 1258844cd2b..6a0cb162549 100644 --- a/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py +++ b/tests/functional/u/unused/unused_name_in_string_literal_type_annotation_py39.py @@ -3,6 +3,7 @@ import graphlib from graphlib import TopologicalSorter + def example( sorter1: "graphlib.TopologicalSorter[int]", sorter2: "TopologicalSorter[str]", diff --git a/tests/functional/u/unused/unused_typing_imports.py b/tests/functional/u/unused/unused_typing_imports.py index 7de4e411bf4..fa3b48f3979 100644 --- a/tests/functional/u/unused/unused_typing_imports.py +++ b/tests/functional/u/unused/unused_typing_imports.py @@ -10,18 +10,8 @@ from collections import Counter as CollectionCounter from collections import defaultdict from datetime import datetime -from typing import ( - Any, - Callable, - Iterable, - List, - NamedTuple, - Optional, - Pattern, - Sequence, - Set, - Tuple, -) +from typing import (Any, Callable, Iterable, List, NamedTuple, Optional, + Pattern, Sequence, Set, Tuple) def func1(arg: Optional[Callable]=None): diff --git a/tests/functional/u/unused/unused_variable.py b/tests/functional/u/unused/unused_variable.py index 0058516c945..afb6d7451a6 100644 --- a/tests/functional/u/unused/unused_variable.py +++ b/tests/functional/u/unused/unused_variable.py @@ -1,11 +1,11 @@ # pylint: disable=missing-docstring, invalid-name, too-few-public-methods, import-outside-toplevel, fixme, line-too-long, broad-exception-raised def test_regression_737(): - import xml # [unused-import] + import xml # [unused-import] def test_regression_923(): import unittest.case # [unused-import] - import xml as sql # [unused-import] + import xml as sql # [unused-import] def test_unused_with_prepended_underscore(): _foo = 42 @@ -51,12 +51,12 @@ def some_other_scope(): def unused_import_from(): - from functools import wraps as abc # [unused-import] - from collections import namedtuple # [unused-import] + from collections import namedtuple # [unused-import] + from functools import wraps as abc # [unused-import] def unused_import_in_function(value): - from string import digits, hexdigits # [unused-import] + from string import digits, hexdigits # [unused-import] return value if value in digits else "Nope" @@ -79,6 +79,8 @@ def function(matches): print(match) from astroid import nodes + + def visit_if(self, node: nodes.If) -> None: """increments the branches counter""" branches = 1 @@ -95,15 +97,16 @@ def test_global(): """ # pylint: disable=redefined-outer-name global PATH, OS, collections, deque # [global-statement] - from os import path as PATH - import os as OS import collections + import os as OS + import re as RE # [unused-import] from collections import deque + from os import path as PATH # make sure that these triggers unused-variable from sys import platform # [unused-import] from sys import version as VERSION # [unused-import] + import this # [unused-import] - import re as RE # [unused-import] # test cases that include exceptions def function2(): diff --git a/tests/functional/u/unused/unused_variable_after_inference.py b/tests/functional/u/unused/unused_variable_after_inference.py index 569564dc921..6590192ec21 100644 --- a/tests/functional/u/unused/unused_variable_after_inference.py +++ b/tests/functional/u/unused/unused_variable_after_inference.py @@ -1,6 +1,8 @@ """Regression test for https://github.com/PyCQA/pylint/issues/6895""" # pylint: disable=missing-class-docstring,too-few-public-methods import argparse + + class Cls: def meth(self): """Enable non-iterator-returned to produce the failure condition""" diff --git a/tests/functional/u/use/use_implicit_booleaness_not_comparison.py b/tests/functional/u/use/use_implicit_booleaness_not_comparison.py index 681ee0607aa..291533739d7 100644 --- a/tests/functional/u/use/use_implicit_booleaness_not_comparison.py +++ b/tests/functional/u/use/use_implicit_booleaness_not_comparison.py @@ -152,6 +152,7 @@ def test_function(): # pylint: disable=import-outside-toplevel, wrong-import-position, import-error # Numpy has its own implementation of __bool__, but base class has list, that's why the comparison check is happening import numpy + numpy_array = numpy.array([0]) if numpy_array == []: # [use-implicit-booleaness-not-comparison] print('numpy_array') @@ -162,6 +163,7 @@ def test_function(): # pandas has its own implementations of __bool__ and is not subclass of list, dict, or tuple; that's why comparison check is not happening import pandas as pd + pandas_df = pd.DataFrame() if pandas_df == []: pass @@ -170,8 +172,8 @@ def test_function(): if pandas_df <= []: print("don't emit warning if variable can't safely be inferred") -from typing import Union from random import random +from typing import Union var: Union[dict, bool, None] = {} if random() > 0.5: diff --git a/tests/functional/u/used/used_before_assignment.py b/tests/functional/u/used/used_before_assignment.py index f8ed651b51f..ed99befb922 100644 --- a/tests/functional/u/used/used_before_assignment.py +++ b/tests/functional/u/used/used_before_assignment.py @@ -16,6 +16,8 @@ def inner(): # pylint: disable=unused-import, wrong-import-position, import-outside-toplevel, reimported, redefined-outer-name, global-statement import time + + def redefine_time_import(): print(time.time()) # [used-before-assignment] import time diff --git a/tests/functional/u/used/used_before_assignment_else_return.py b/tests/functional/u/used/used_before_assignment_else_return.py index a7e58bb61f6..e516d2808a3 100644 --- a/tests/functional/u/used/used_before_assignment_else_return.py +++ b/tests/functional/u/used/used_before_assignment_else_return.py @@ -2,6 +2,7 @@ # pylint: disable=missing-function-docstring, invalid-name import sys + def valid(): """https://github.com/PyCQA/pylint/issues/6790""" try: diff --git a/tests/functional/u/used/used_before_assignment_py37.py b/tests/functional/u/used/used_before_assignment_py37.py index c64bf7cf55e..13ba861c5e4 100644 --- a/tests/functional/u/used/used_before_assignment_py37.py +++ b/tests/functional/u/used/used_before_assignment_py37.py @@ -1,6 +1,7 @@ """Tests for used-before-assignment with functions added in python 3.7""" # pylint: disable=missing-function-docstring from __future__ import annotations + from collections import namedtuple from typing import List diff --git a/tests/functional/u/used/used_before_assignment_type_annotations.py b/tests/functional/u/used/used_before_assignment_type_annotations.py index 1a03050c34c..f695aff5cbc 100644 --- a/tests/functional/u/used/used_before_assignment_type_annotations.py +++ b/tests/functional/u/used/used_before_assignment_type_annotations.py @@ -3,6 +3,7 @@ from collections import namedtuple from typing import List + def value_and_type_assignment(): """The variable assigned a value and type""" variable: int = 2 diff --git a/tests/functional/u/used/used_before_assignment_typing.py b/tests/functional/u/used/used_before_assignment_typing.py index a6ad926178c..19e5ea71710 100644 --- a/tests/functional/u/used/used_before_assignment_typing.py +++ b/tests/functional/u/used/used_before_assignment_typing.py @@ -2,7 +2,7 @@ # pylint: disable=missing-function-docstring -from typing import List, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, List, Optional if TYPE_CHECKING: import datetime diff --git a/tests/functional/u/useless/useless_object_inheritance.py b/tests/functional/u/useless/useless_object_inheritance.py index 5c23d2147e6..61edd6a5054 100644 --- a/tests/functional/u/useless/useless_object_inheritance.py +++ b/tests/functional/u/useless/useless_object_inheritance.py @@ -5,6 +5,7 @@ # pylint: disable=inconsistent-mro import abc + class A(object): # [useless-object-inheritance] pass diff --git a/tests/functional/u/useless/useless_suppression.py b/tests/functional/u/useless/useless_suppression.py index b5c681eefe1..68305dda619 100644 --- a/tests/functional/u/useless/useless_suppression.py +++ b/tests/functional/u/useless/useless_suppression.py @@ -2,10 +2,11 @@ # pylint: enable=useless-suppression, line-too-long # pylint: disable=unused-import, wrong-import-order, wrong-import-position +import astroid + # False positive for wrong-import-order # Reported in https://github.com/PyCQA/pylint/issues/2366 from pylint import run_pylint -import astroid # False-positive for 'line-too-long' # Reported in https://github.com/PyCQA/pylint/issues/4212 diff --git a/tests/functional/u/useless/useless_with_lock.py b/tests/functional/u/useless/useless_with_lock.py index 19d664084da..40f82f8270c 100644 --- a/tests/functional/u/useless/useless_with_lock.py +++ b/tests/functional/u/useless/useless_with_lock.py @@ -1,8 +1,7 @@ """Tests for the useless-with-lock message""" # pylint: disable=missing-docstring import threading -from threading import Lock, RLock, Condition, Semaphore, BoundedSemaphore - +from threading import BoundedSemaphore, Condition, Lock, RLock, Semaphore with threading.Lock(): # [useless-with-lock] ... diff --git a/tests/functional/w/wildcard_import.py b/tests/functional/w/wildcard_import.py index 4034162e0f3..74670f8fd9d 100644 --- a/tests/functional/w/wildcard_import.py +++ b/tests/functional/w/wildcard_import.py @@ -1,5 +1,5 @@ # pylint: disable=missing-docstring,import-error,unused-wildcard-import -from indirect1 import * # [wildcard-import] +from indirect1 import * # [wildcard-import] # This is an unresolved import which still generates the wildcard-import # warning. -from unknown.package import * # [wildcard-import] +from unknown.package import * # [wildcard-import] diff --git a/tests/functional/w/wildcard_import_allowed.py b/tests/functional/w/wildcard_import_allowed.py index 21fea473816..b6100db2c2b 100644 --- a/tests/functional/w/wildcard_import_allowed.py +++ b/tests/functional/w/wildcard_import_allowed.py @@ -1,4 +1,5 @@ # pylint: disable=missing-docstring,unused-wildcard-import,redefined-builtin,import-error -from csv import * from abc import * # [wildcard-import] +from csv import * + from UNINFERABLE import * # [wildcard-import] diff --git a/tests/functional/w/wrong_import_order.py b/tests/functional/w/wrong_import_order.py index ed0615b0c09..4bd2891eca6 100644 --- a/tests/functional/w/wrong_import_order.py +++ b/tests/functional/w/wrong_import_order.py @@ -1,43 +1,45 @@ """Checks import order rule""" # pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level from __future__ import absolute_import + try: from six.moves import configparser except ImportError: import configparser +import datetime # [wrong-import-order] import logging - -import six import os.path # [wrong-import-order] -from astroid import are_exclusive import sys # [wrong-import-order] -import datetime # [wrong-import-order] + +import astroid # [wrong-import-order] +import six +import totally_missing # [wrong-import-order] import unused_import +from astroid import are_exclusive +from six.moves.urllib.parse import quote # [wrong-import-order] + +from ..package3 import Class3 +from . import package, package2 from .package import Class -import totally_missing # [wrong-import-order] -from . import package -import astroid # [wrong-import-order] -from . import package2 from .package2 import Class2 -from ..package3 import Class3 -from six.moves.urllib.parse import quote # [wrong-import-order] - LOGGER = logging.getLogger(__name__) if LOGGER: # imports nested skipped - from . import package4 import pprint from pprint import PrettyPrinter + from . import package4 + try: # imports nested skipped - from . import package4 import random from random import division + + from . import package4 except ImportError: LOGGER.info('A useful message here') diff --git a/tests/functional/w/wrong_import_order2.py b/tests/functional/w/wrong_import_order2.py index 7157512ddce..ce276861fa8 100644 --- a/tests/functional/w/wrong_import_order2.py +++ b/tests/functional/w/wrong_import_order2.py @@ -8,7 +8,6 @@ # external imports import isort - from six import moves # local_imports diff --git a/tests/functional/w/wrong_import_position.py b/tests/functional/w/wrong_import_position.py index 7d1fddfa3bf..cb7ca48140a 100644 --- a/tests/functional/w/wrong_import_position.py +++ b/tests/functional/w/wrong_import_position.py @@ -29,5 +29,5 @@ def some_func(self): for i in range(10): VAR += i -import scipy # [wrong-import-position] import astroid # [wrong-import-position] +import scipy # [wrong-import-position] diff --git a/tests/functional/w/wrong_import_position9.py b/tests/functional/w/wrong_import_position9.py index 232c453ccb5..f36e3d6f6b8 100644 --- a/tests/functional/w/wrong_import_position9.py +++ b/tests/functional/w/wrong_import_position9.py @@ -1,6 +1,7 @@ """Checks import position rule""" # pylint: disable=unused-import,ungrouped-imports,import-error,no-name-in-module,relative-beyond-top-level import y + try: import x except ImportError: diff --git a/tests/functional/w/wrong_import_position_exclude_dunder_main.py b/tests/functional/w/wrong_import_position_exclude_dunder_main.py index 05f680377a1..385dd4a9293 100644 --- a/tests/functional/w/wrong_import_position_exclude_dunder_main.py +++ b/tests/functional/w/wrong_import_position_exclude_dunder_main.py @@ -7,6 +7,7 @@ for i in range(10): VAR += i - import six import datetime + import astroid + import six diff --git a/tests/input/func_3k_removed_stuff_py_30.py b/tests/input/func_3k_removed_stuff_py_30.py index d844c560316..d0c052bfa35 100644 --- a/tests/input/func_3k_removed_stuff_py_30.py +++ b/tests/input/func_3k_removed_stuff_py_30.py @@ -1,7 +1,9 @@ """test relative import""" from __future__ import print_function + import func_w0401 + __revision__ = filter(None, map(str, (1, 2, 3))) diff --git a/tests/input/func_w0401_package/all_the_things.py b/tests/input/func_w0401_package/all_the_things.py index 64556e1be32..ce4d84c46dc 100644 --- a/tests/input/func_w0401_package/all_the_things.py +++ b/tests/input/func_w0401_package/all_the_things.py @@ -1,8 +1,8 @@ """All the things!""" from .thing1 import THING1 -from .thing2 import THING2 -from .thing2 import THING1_PLUS_THING2 +from .thing2 import THING1_PLUS_THING2, THING2 + __revision__ = None _ = (THING1, THING2, THING1_PLUS_THING2) diff --git a/tests/input/func_w0401_package/thing2.py b/tests/input/func_w0401_package/thing2.py index d7a0f223917..e0bdb1094df 100644 --- a/tests/input/func_w0401_package/thing2.py +++ b/tests/input/func_w0401_package/thing2.py @@ -1,6 +1,7 @@ """The second thing.""" from .all_the_things import THING1 + __revision__ = None THING2 = "I am thing2" diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index 25df951df4b..ce7049fa441 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -28,16 +28,10 @@ from pylint import checkers, config, exceptions, interfaces, lint, testutils from pylint.checkers.utils import only_required_for_messages -from pylint.constants import ( - MSG_STATE_CONFIDENCE, - MSG_STATE_SCOPE_CONFIG, - MSG_STATE_SCOPE_MODULE, - OLD_DEFAULT_PYLINT_HOME, - PYLINT_HOME, - USER_HOME, - _get_pylint_home, - _warn_about_old_home, -) +from pylint.constants import (MSG_STATE_CONFIDENCE, MSG_STATE_SCOPE_CONFIG, + MSG_STATE_SCOPE_MODULE, OLD_DEFAULT_PYLINT_HOME, + PYLINT_HOME, USER_HOME, _get_pylint_home, + _warn_about_old_home) from pylint.exceptions import InvalidMessageError from pylint.lint import PyLinter from pylint.lint.utils import fix_import_path diff --git a/tests/message/conftest.py b/tests/message/conftest.py index e4105783506..c8252890001 100644 --- a/tests/message/conftest.py +++ b/tests/message/conftest.py @@ -12,7 +12,8 @@ from pylint.checkers import BaseChecker from pylint.lint.pylinter import PyLinter -from pylint.message import MessageDefinition, MessageDefinitionStore, MessageIdStore +from pylint.message import (MessageDefinition, MessageDefinitionStore, + MessageIdStore) @pytest.fixture diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py index 9a550c5db6f..b15be6dd480 100644 --- a/tests/pyreverse/test_diadefs.py +++ b/tests/pyreverse/test_diadefs.py @@ -15,12 +15,9 @@ import pytest from astroid import nodes -from pylint.pyreverse.diadefslib import ( - ClassDiadefGenerator, - DefaultDiadefGenerator, - DiaDefGenerator, - DiadefsHandler, -) +from pylint.pyreverse.diadefslib import (ClassDiadefGenerator, + DefaultDiadefGenerator, + DiaDefGenerator, DiadefsHandler) from pylint.pyreverse.diagrams import DiagramEntity, Relationship from pylint.pyreverse.inspector import Linker, Project from pylint.testutils.pyreverse import PyreverseConfig diff --git a/tests/pyreverse/test_pyreverse_functional.py b/tests/pyreverse/test_pyreverse_functional.py index 15fd1978b66..9a23582dc21 100644 --- a/tests/pyreverse/test_pyreverse_functional.py +++ b/tests/pyreverse/test_pyreverse_functional.py @@ -7,10 +7,8 @@ import pytest from pylint.pyreverse.main import Run -from pylint.testutils.pyreverse import ( - FunctionalPyreverseTestfile, - get_functional_test_files, -) +from pylint.testutils.pyreverse import (FunctionalPyreverseTestfile, + get_functional_test_files) FUNCTIONAL_DIR = Path(__file__).parent / "functional" CLASS_DIAGRAM_TESTS = get_functional_test_files(FUNCTIONAL_DIR / "class_diagrams") diff --git a/tests/pyreverse/test_utils.py b/tests/pyreverse/test_utils.py index d64bf4fa70e..36fcb75487f 100644 --- a/tests/pyreverse/test_utils.py +++ b/tests/pyreverse/test_utils.py @@ -13,12 +13,8 @@ import pytest from astroid import nodes -from pylint.pyreverse.utils import ( - get_annotation, - get_annotation_label, - get_visibility, - infer_node, -) +from pylint.pyreverse.utils import (get_annotation, get_annotation_label, + get_visibility, infer_node) @pytest.mark.parametrize( diff --git a/tests/regrtest_data/absimp/string.py b/tests/regrtest_data/absimp/string.py index 9a60e26ab33..c9a0bb9c8a2 100644 --- a/tests/regrtest_data/absimp/string.py +++ b/tests/regrtest_data/absimp/string.py @@ -3,5 +3,7 @@ https://www.logilab.org/ticket/70565 """ from __future__ import absolute_import, print_function + import string + print(string) diff --git a/tests/regrtest_data/bad_package/__init__.py b/tests/regrtest_data/bad_package/__init__.py index 16c3a156225..eaa0b4f23d0 100644 --- a/tests/regrtest_data/bad_package/__init__.py +++ b/tests/regrtest_data/bad_package/__init__.py @@ -1,2 +1,3 @@ import missing -raise missing.Missing.. + +raise missing.Missing.. diff --git a/tests/regrtest_data/beyond_top/__init__.py b/tests/regrtest_data/beyond_top/__init__.py index 788cf4510ad..61dd8150dfd 100644 --- a/tests/regrtest_data/beyond_top/__init__.py +++ b/tests/regrtest_data/beyond_top/__init__.py @@ -1,5 +1,6 @@ from ... import Something from . import data + try: from ... import Lala except ImportError: diff --git a/tests/regrtest_data/decimal_inference.py b/tests/regrtest_data/decimal_inference.py index 00c9130402d..69c5158d06a 100644 --- a/tests/regrtest_data/decimal_inference.py +++ b/tests/regrtest_data/decimal_inference.py @@ -4,6 +4,7 @@ 2007/02/17 update: .prec attribute is now detected by astroid :o) """ from __future__ import print_function + import decimal decimal.getcontext().prec = 200 diff --git a/tests/regrtest_data/descriptor_crash.py b/tests/regrtest_data/descriptor_crash.py index 4b3adccdefc..c05b825a80b 100644 --- a/tests/regrtest_data/descriptor_crash.py +++ b/tests/regrtest_data/descriptor_crash.py @@ -2,6 +2,7 @@ import urllib + class Page(object): _urlOpen = staticmethod(urllib.urlopen) diff --git a/tests/regrtest_data/dummy/__init__.py b/tests/regrtest_data/dummy/__init__.py index 0b43a7096df..f31718d5c9d 100644 --- a/tests/regrtest_data/dummy/__init__.py +++ b/tests/regrtest_data/dummy/__init__.py @@ -1,3 +1,3 @@ # pylint: disable=missing-docstring -from .dummy import DUMMY from .another import ANOTHER +from .dummy import DUMMY diff --git a/tests/regrtest_data/fail_on.py b/tests/regrtest_data/fail_on.py index 6f22e5013f0..66063ee6e78 100644 --- a/tests/regrtest_data/fail_on.py +++ b/tests/regrtest_data/fail_on.py @@ -2,6 +2,7 @@ Pylint score: -1.67 """ import nonexistent + # pylint: disable=broad-except diff --git a/tests/regrtest_data/fail_under_plus7_5.py b/tests/regrtest_data/fail_under_plus7_5.py index fea27f4ecb8..7f8d1ea509b 100644 --- a/tests/regrtest_data/fail_under_plus7_5.py +++ b/tests/regrtest_data/fail_under_plus7_5.py @@ -4,6 +4,7 @@ import os + def func(): path = '/tmp' os.path.exists(path) diff --git a/tests/regrtest_data/func_block_disable_msg.py b/tests/regrtest_data/func_block_disable_msg.py index a1dd9a627cd..a734debff81 100644 --- a/tests/regrtest_data/func_block_disable_msg.py +++ b/tests/regrtest_data/func_block_disable_msg.py @@ -2,6 +2,7 @@ """pylint option block-disable""" from __future__ import print_function + class Foo: """block-disable test""" diff --git a/tests/regrtest_data/hang/pkg4972/string/__init__.py b/tests/regrtest_data/hang/pkg4972/string/__init__.py index 4a77f25ac2f..7faad7222ce 100644 --- a/tests/regrtest_data/hang/pkg4972/string/__init__.py +++ b/tests/regrtest_data/hang/pkg4972/string/__init__.py @@ -1,6 +1,8 @@ import string + import pkg4972.string # self-import necessary + class Fake(string.Formatter): pass diff --git a/tests/regrtest_data/import_assign.py b/tests/regrtest_data/import_assign.py index c01cd52f727..631e64ed5c8 100644 --- a/tests/regrtest_data/import_assign.py +++ b/tests/regrtest_data/import_assign.py @@ -1,5 +1,6 @@ -import shmixml.dom.minidom import xml.dom.minidom +import shmixml.dom.minidom + if 'dom' not in xml.__dict__: xml.dom = shmixml.dom diff --git a/tests/regrtest_data/import_package_subpackage_module.py b/tests/regrtest_data/import_package_subpackage_module.py index 2864e3c9efc..9626ba37967 100644 --- a/tests/regrtest_data/import_package_subpackage_module.py +++ b/tests/regrtest_data/import_package_subpackage_module.py @@ -46,4 +46,5 @@ (3) run pylint with a script importing package.subpackage.module. """ import package.subpackage.module + __revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 16:08:54 syt Exp $' diff --git a/tests/regrtest_data/imported_module_in_typehint/module_a.py b/tests/regrtest_data/imported_module_in_typehint/module_a.py index d9754eca4c2..ed68a058a4d 100644 --- a/tests/regrtest_data/imported_module_in_typehint/module_a.py +++ b/tests/regrtest_data/imported_module_in_typehint/module_a.py @@ -1,5 +1,4 @@ import uuid from typing import Optional - ID = None # type: Optional[uuid.UUID] diff --git a/tests/regrtest_data/numarray_inf.py b/tests/regrtest_data/numarray_inf.py index 4ea22a9c6e1..bc2ecb735aa 100644 --- a/tests/regrtest_data/numarray_inf.py +++ b/tests/regrtest_data/numarray_inf.py @@ -2,4 +2,5 @@ import numarray as na import numarray.random_array as nar + IM16 = nar.randint(0, 256, 300).astype(na.UInt8) diff --git a/tests/regrtest_data/precedence_test.py b/tests/regrtest_data/precedence_test.py index ff5871d467d..dbb07e46a49 100644 --- a/tests/regrtest_data/precedence_test.py +++ b/tests/regrtest_data/precedence_test.py @@ -14,7 +14,9 @@ class AudioTime(object): """ from __future__ import print_function + from package import AudioTime + __revision__ = 0 diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py index 15b59304c01..21ba2ce86a4 100644 --- a/tests/test_check_parallel.py +++ b/tests/test_check_parallel.py @@ -21,7 +21,8 @@ import pylint.lint.parallel from pylint.checkers import BaseRawFileChecker from pylint.lint import PyLinter -from pylint.lint.parallel import _worker_check_single_file as worker_check_single_file +from pylint.lint.parallel import \ + _worker_check_single_file as worker_check_single_file from pylint.lint.parallel import _worker_initialize as worker_initialize from pylint.lint.parallel import check_parallel from pylint.testutils import GenericTestReporter as Reporter diff --git a/tests/test_deprecation.py b/tests/test_deprecation.py index 1c1d132a8ae..64704b06fae 100644 --- a/tests/test_deprecation.py +++ b/tests/test_deprecation.py @@ -14,14 +14,8 @@ from pylint.checkers import BaseChecker from pylint.checkers.mapreduce_checker import MapReduceMixin from pylint.config import load_results, save_results -from pylint.interfaces import ( - IAstroidChecker, - IChecker, - Interface, - IRawChecker, - IReporter, - ITokenChecker, -) +from pylint.interfaces import (IAstroidChecker, IChecker, Interface, + IRawChecker, IReporter, ITokenChecker) from pylint.lint import PyLinter from pylint.message import MessageDefinitionStore from pylint.reporters import BaseReporter diff --git a/tests/test_func.py b/tests/test_func.py index 493489aeef9..5aacf5211b6 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -12,7 +12,8 @@ import pytest -from pylint.testutils import UPDATE_FILE, UPDATE_OPTION, _get_tests_info, linter +from pylint.testutils import (UPDATE_FILE, UPDATE_OPTION, _get_tests_info, + linter) from pylint.testutils.reporter_for_tests import GenericTestReporter from pylint.testutils.utils import _test_cwd diff --git a/tests/test_functional.py b/tests/test_functional.py index 77cdbc58f85..6f1c55c62b6 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -15,10 +15,8 @@ from pylint import testutils from pylint.testutils import UPDATE_FILE, UPDATE_OPTION from pylint.testutils.functional import ( - FunctionalTestFile, - LintModuleOutputUpdate, - get_functional_test_files_from_directory, -) + FunctionalTestFile, LintModuleOutputUpdate, + get_functional_test_files_from_directory) from pylint.utils import HAS_ISORT_5 FUNCTIONAL_DIR = Path(__file__).parent.resolve() / "functional" diff --git a/tests/test_functional_directories.py b/tests/test_functional_directories.py index f7577233229..83b2444f7f4 100644 --- a/tests/test_functional_directories.py +++ b/tests/test_functional_directories.py @@ -5,9 +5,8 @@ """Test that the directory structure of the functional tests is correct.""" from pathlib import Path -from pylint.testutils.functional.find_functional_tests import ( - get_functional_test_files_from_directory, -) +from pylint.testutils.functional.find_functional_tests import \ + get_functional_test_files_from_directory def test_directories() -> None: diff --git a/tests/test_pragma_parser.py b/tests/test_pragma_parser.py index 7db8606690a..f4c0818bfc5 100644 --- a/tests/test_pragma_parser.py +++ b/tests/test_pragma_parser.py @@ -4,12 +4,8 @@ import pytest -from pylint.utils.pragma_parser import ( - OPTION_PO, - InvalidPragmaError, - UnRecognizedOptionError, - parse_pragma, -) +from pylint.utils.pragma_parser import (OPTION_PO, InvalidPragmaError, + UnRecognizedOptionError, parse_pragma) def test_simple_pragma() -> None: diff --git a/tests/test_self.py b/tests/test_self.py index 587b8bb589f..7af96212681 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -36,12 +36,8 @@ from pylint.reporters.text import ColorizedTextReporter, TextReporter from pylint.testutils._run import _add_rcfile_default_pylintrc from pylint.testutils._run import _Run as Run -from pylint.testutils.utils import ( - _patch_streams, - _test_cwd, - _test_environ_pythonpath, - _test_sys_path, -) +from pylint.testutils.utils import (_patch_streams, _test_cwd, + _test_environ_pythonpath, _test_sys_path) from pylint.utils import utils if sys.version_info >= (3, 11): diff --git a/tests/testutils/test_functional_testutils.py b/tests/testutils/test_functional_testutils.py index 68dad697d46..6159d636854 100644 --- a/tests/testutils/test_functional_testutils.py +++ b/tests/testutils/test_functional_testutils.py @@ -12,9 +12,7 @@ from pylint import testutils from pylint.testutils.functional import ( - FunctionalTestFile, - get_functional_test_files_from_directory, -) + FunctionalTestFile, get_functional_test_files_from_directory) HERE = Path(__file__).parent DATA_DIRECTORY = HERE / "data" diff --git a/tests/testutils/test_testutils_utils.py b/tests/testutils/test_testutils_utils.py index b521e25c4c4..0d1bae93e27 100644 --- a/tests/testutils/test_testutils_utils.py +++ b/tests/testutils/test_testutils_utils.py @@ -8,7 +8,8 @@ import pytest -from pylint.testutils.utils import _test_cwd, _test_environ_pythonpath, _test_sys_path +from pylint.testutils.utils import (_test_cwd, _test_environ_pythonpath, + _test_sys_path) def test__test_sys_path_no_arg() -> None: