wemake-python-styleguide
Advanced tools
+1
-1
| Metadata-Version: 2.3 | ||
| Name: wemake-python-styleguide | ||
| Version: 1.3.0 | ||
| Version: 1.4.0 | ||
| Summary: The strictest and most opinionated python linter ever | ||
@@ -5,0 +5,0 @@ License: MIT |
+4
-2
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "wemake-python-styleguide" | ||
| version = "1.3.0" | ||
| version = "1.4.0" | ||
| description = "The strictest and most opinionated python linter ever" | ||
@@ -69,3 +69,3 @@ | ||
| mypy = "^1.16" | ||
| mypy = "^1.17" | ||
| types-flake8 = "^7.3" | ||
@@ -135,2 +135,3 @@ | ||
| "F", # pyflakes | ||
| "FA", # flake8-future-annotations | ||
| "FBT", # flake8-boolean-trap | ||
@@ -266,2 +267,3 @@ "FLY", # pyflint | ||
| "deprecated", | ||
| "exhaustive-match", | ||
| ] | ||
@@ -268,0 +270,0 @@ |
@@ -9,3 +9,4 @@ import argparse | ||
| parser = argparse.ArgumentParser( | ||
| prog='wps', description='WPS command line tool' | ||
| prog='wps', | ||
| description='WPS command line tool', | ||
| ) | ||
@@ -12,0 +13,0 @@ sub_parsers = parser.add_subparsers( |
@@ -19,5 +19,5 @@ """Provides tools for formatting explanations.""" | ||
| cleaned_docstring = _remove_newlines_at_ends( | ||
| textwrap.dedent(violation.docstring) | ||
| textwrap.dedent(violation.docstring), | ||
| ) | ||
| violation_url = SHORTLINK_TEMPLATE.format(f'WPS{violation.code}') | ||
| return f'{cleaned_docstring}\n\nSee at website: {violation_url}' |
@@ -422,5 +422,2 @@ """ | ||
| #: Maximum number of conditions in a single ``if`` or ``while`` statement. | ||
| MAX_CONDITIONS: Final = 4 | ||
| #: Maximum number of `elif` blocks in a single `if` condition: | ||
@@ -427,0 +424,0 @@ MAX_ELIFS: Final = 3 |
@@ -112,3 +112,4 @@ import ast | ||
| if isinstance(node.operand, ast.Constant) and isinstance( | ||
| node.operand.value, int | ||
| node.operand.value, | ||
| int, | ||
| ): | ||
@@ -115,0 +116,0 @@ return node.operand.value == 1 |
@@ -6,2 +6,3 @@ import ast | ||
| from wemake_python_styleguide.logic.source import node_to_string | ||
| from wemake_python_styleguide.options.validation import ValidatedOptions | ||
@@ -47,3 +48,4 @@ _CONCRETE_ENUM_NAMES: Final = ( | ||
| def _has_one_of_base_classes( | ||
| defn: ast.ClassDef, base_names: Collection[str] | ||
| defn: ast.ClassDef, | ||
| base_names: Collection[str], | ||
| ) -> bool: | ||
@@ -72,1 +74,24 @@ """Tells whether some class has one of provided names as its base.""" | ||
| return _has_one_of_base_classes(defn, _ENUM_LIKE_NAMES) | ||
| def has_enum_like_base_with_config( | ||
| defn: ast.ClassDef, | ||
| config: ValidatedOptions, | ||
| ) -> bool: | ||
| """ | ||
| Tells if some class has `Enum` or semantically similar class as its base. | ||
| This function also checks user-defined enum-like base classes from | ||
| configuration. | ||
| """ | ||
| if has_enum_like_base(defn): | ||
| return True | ||
| enum_bases = config.known_enum_bases | ||
| if enum_bases: | ||
| normalized: tuple[str, ...] = tuple({ | ||
| name for base in enum_bases for name in (base, base.split('.')[-1]) | ||
| }) | ||
| return _has_one_of_base_classes(defn, normalized) | ||
| return False |
@@ -61,2 +61,5 @@ """ | ||
| :str:`wemake_python_styleguide.options.defaults.EXPS_FOR_ONE_EMPTY_LINE` | ||
| - ``known-enum-bases`` - list of additional enum-like base class names that | ||
| should be treated as enums, defaults to | ||
| :str:`wemake_python_styleguide.options.defaults.KNOWN_ENUM_BASES` | ||
@@ -163,2 +166,6 @@ | ||
| :str:`wemake_python_styleguide.options.defaults.MAX_LINES_IN_FINALLY` | ||
| - ``max-conditions`` - Maximum number of conditions in a single boolop | ||
| expression. | ||
| defaults to | ||
| :str:`wemake_python_styleguide.options.defaults.MAX_CONDITIONS` | ||
@@ -284,2 +291,10 @@ .. rubric:: Formatter options | ||
| ), | ||
| _Option( | ||
| '--known-enum-bases', | ||
| defaults.KNOWN_ENUM_BASES, | ||
| 'List of additional enum-like base class names that should be ' | ||
| 'treated as enums.', | ||
| type=String, | ||
| comma_separated_list=True, | ||
| ), | ||
| # Complexity: | ||
@@ -446,2 +461,8 @@ _Option( | ||
| ), | ||
| _Option( | ||
| '--max-conditions', | ||
| defaults.MAX_CONDITIONS, | ||
| 'Maximum number of conditions in a single ``if`` or ``while`` ' | ||
| 'statement.', | ||
| ), | ||
| # Formatter: | ||
@@ -448,0 +469,0 @@ _Option( |
@@ -37,2 +37,5 @@ """ | ||
| #: List of additional enum-like base class names. | ||
| KNOWN_ENUM_BASES: Final = () | ||
| #: Domain names that are removed from variable names' blacklist. | ||
@@ -156,2 +159,6 @@ ALLOWED_DOMAIN_NAMES: Final = () | ||
| #: Maximum number of conditions in a single ``if`` or ``while`` statement. | ||
| MAX_CONDITIONS: Final = 4 # reasonable enough | ||
| # ========== | ||
@@ -158,0 +165,0 @@ # Formatter: |
@@ -66,2 +66,3 @@ from typing import Any, final | ||
| nested_classes_whitelist: tuple[str, ...] = attr.ib(converter=tuple) | ||
| known_enum_bases: tuple[str, ...] = attr.ib(converter=tuple) | ||
| allowed_domain_names: tuple[str, ...] = attr.ib(converter=tuple) | ||
@@ -106,2 +107,3 @@ forbidden_domain_names: tuple[str, ...] = attr.ib(converter=tuple) | ||
| max_lines_in_finally: int = attr.ib(validator=[_min_max(min=1)]) | ||
| max_conditions: int = attr.ib(validator=[_min_max(min=1)]) | ||
| show_violation_links: bool | ||
@@ -108,0 +110,0 @@ exps_for_one_empty_line: int |
@@ -22,95 +22,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| JonesScoreViolation | ||
| TooManyImportsViolation | ||
| TooManyModuleMembersViolation | ||
| TooManyImportedNamesViolation | ||
| OverusedExpressionViolation | ||
| TooManyLocalsViolation | ||
| TooManyArgumentsViolation | ||
| TooManyReturnsViolation | ||
| TooManyExpressionsViolation | ||
| TooManyMethodsViolation | ||
| TooManyBaseClassesViolation | ||
| TooManyDecoratorsViolation | ||
| TooManyAwaitsViolation | ||
| TooManyAssertsViolation | ||
| TooDeepAccessViolation | ||
| TooDeepNestingViolation | ||
| LineComplexityViolation | ||
| TooManyConditionsViolation | ||
| TooManyElifsViolation | ||
| TooManyForsInComprehensionViolation | ||
| TooManyExceptCasesViolation | ||
| OverusedStringViolation | ||
| TooLongOutputTupleViolation | ||
| TooLongCompareViolation | ||
| TooLongTryBodyViolation | ||
| TooManyPublicAttributesViolation | ||
| CognitiveComplexityViolation | ||
| CognitiveModuleComplexityViolation | ||
| TooLongCallChainViolation | ||
| TooComplexAnnotationViolation | ||
| TooManyImportedModuleMembersViolation | ||
| TooLongTupleUnpackViolation | ||
| TooComplexFormattedStringViolation | ||
| TooManyRaisesViolation | ||
| TooManyExceptExceptionsViolation | ||
| TooManyTypeParamsViolation | ||
| TooManyMatchSubjectsViolation | ||
| TooManyMatchCaseViolation | ||
| TooLongFinallyBodyViolation | ||
| Module complexity | ||
| ----------------- | ||
| .. autoclass:: JonesScoreViolation | ||
| .. autoclass:: TooManyImportsViolation | ||
| .. autoclass:: TooManyModuleMembersViolation | ||
| .. autoclass:: TooManyImportedNamesViolation | ||
| .. autoclass:: OverusedExpressionViolation | ||
| Structure complexity | ||
| -------------------- | ||
| .. autoclass:: TooManyLocalsViolation | ||
| .. autoclass:: TooManyArgumentsViolation | ||
| .. autoclass:: TooManyReturnsViolation | ||
| .. autoclass:: TooManyExpressionsViolation | ||
| .. autoclass:: TooManyMethodsViolation | ||
| .. autoclass:: TooManyBaseClassesViolation | ||
| .. autoclass:: TooManyDecoratorsViolation | ||
| .. autoclass:: TooManyAwaitsViolation | ||
| .. autoclass:: TooManyAssertsViolation | ||
| .. autoclass:: TooDeepAccessViolation | ||
| .. autoclass:: TooDeepNestingViolation | ||
| .. autoclass:: LineComplexityViolation | ||
| .. autoclass:: TooManyConditionsViolation | ||
| .. autoclass:: TooManyElifsViolation | ||
| .. autoclass:: TooManyForsInComprehensionViolation | ||
| .. autoclass:: TooManyExceptCasesViolation | ||
| .. autoclass:: OverusedStringViolation | ||
| .. autoclass:: TooLongOutputTupleViolation | ||
| .. autoclass:: TooLongCompareViolation | ||
| .. autoclass:: TooLongTryBodyViolation | ||
| .. autoclass:: TooManyPublicAttributesViolation | ||
| .. autoclass:: CognitiveComplexityViolation | ||
| .. autoclass:: CognitiveModuleComplexityViolation | ||
| .. autoclass:: TooLongCallChainViolation | ||
| .. autoclass:: TooComplexAnnotationViolation | ||
| .. autoclass:: TooManyImportedModuleMembersViolation | ||
| .. autoclass:: TooLongTupleUnpackViolation | ||
| .. autoclass:: TooComplexFormattedStringViolation | ||
| .. autoclass:: TooManyRaisesViolation | ||
| .. autoclass:: TooManyExceptExceptionsViolation | ||
| .. autoclass:: TooManyTypeParamsViolation | ||
| .. autoclass:: TooManyMatchSubjectsViolation | ||
| .. autoclass:: TooManyMatchCaseViolation | ||
| .. autoclass:: TooLongFinallyBodyViolation | ||
| """ | ||
@@ -762,3 +669,3 @@ | ||
| We use :str:`wemake_python_styleguide.constants.MAX_CONDITIONS` | ||
| We use :str:`wemake_python_styleguide.options.defaults.MAX_CONDITIONS` | ||
| as a default value. | ||
@@ -776,2 +683,7 @@ | ||
| Configuration: | ||
| This rule is configurable with ``--max-conditions``. | ||
| Default: | ||
| :str:`wemake_python_styleguide.options.defaults.MAX_CONDITIONS` | ||
| We count ``and`` and ``or`` keywords as conditions. | ||
@@ -781,3 +693,4 @@ | ||
| .. versionchanged:: 0.5.0 | ||
| .. versionchanged:: 1.4.0 | ||
| Added ``--max-conditions`` configuration options. | ||
| """ | ||
@@ -784,0 +697,0 @@ |
@@ -20,141 +20,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| LocalFolderImportViolation | ||
| DottedRawImportViolation | ||
| UnicodeStringViolation | ||
| UnderscoredNumberViolation | ||
| PartialFloatViolation | ||
| FormattedStringViolation | ||
| ExplicitObjectBaseClassViolation | ||
| MultipleIfsInComprehensionViolation | ||
| ConstantCompareViolation | ||
| CompareOrderViolation | ||
| BadNumberSuffixViolation | ||
| MultipleInCompareViolation | ||
| UselessCompareViolation | ||
| MissingSpaceBetweenKeywordAndParenViolation | ||
| ConstantConditionViolation | ||
| ObjectInBaseClassesListViolation | ||
| MultipleContextManagerAssignmentsViolation | ||
| ParametersIndentationViolation | ||
| ExtraIndentationViolation | ||
| WrongBracketPositionViolation | ||
| MultilineFunctionAnnotationViolation | ||
| UppercaseStringModifierViolation | ||
| UselessMultilineStringViolation | ||
| ModuloStringFormatViolation | ||
| InconsistentReturnViolation | ||
| InconsistentYieldViolation | ||
| ImplicitStringConcatenationViolation | ||
| UselessContinueViolation | ||
| UselessNodeViolation | ||
| UselessExceptCaseViolation | ||
| UselessOperatorsViolation | ||
| InconsistentReturnVariableViolation | ||
| WalrusViolation | ||
| ImplicitComplexCompareViolation | ||
| ReversedComplexCompareViolation | ||
| WrongLoopIterTypeViolation | ||
| ExplicitStringConcatViolation | ||
| MultilineConditionsViolation | ||
| WrongMethodOrderViolation | ||
| NumberWithMeaninglessZeroViolation | ||
| PositiveExponentViolation | ||
| WrongHexNumberCaseViolation | ||
| ImplicitRawStringViolation | ||
| BadComplexNumberSuffixViolation | ||
| ZeroDivisionViolation | ||
| MeaninglessNumberOperationViolation | ||
| OperationSignNegationViolation | ||
| VagueImportViolation | ||
| LineStartsWithDotViolation | ||
| RedundantSubscriptViolation | ||
| AugmentedAssignPatternViolation | ||
| UnnecessaryLiteralsViolation | ||
| MultilineLoopViolation | ||
| IncorrectYieldFromTargetViolation | ||
| ConsecutiveYieldsViolation | ||
| BracketBlankLineViolation | ||
| IterableUnpackingViolation | ||
| LineCompriseCarriageReturnViolation | ||
| FloatZeroViolation | ||
| UnpackingIterableToListViolation | ||
| RawStringNotNeededViolation | ||
| InconsistentComprehensionViolation | ||
| AssignToSliceViolation | ||
| RaiseSystemExitViolation | ||
| Consistency checks | ||
| ------------------ | ||
| .. autoclass:: LocalFolderImportViolation | ||
| .. autoclass:: DottedRawImportViolation | ||
| .. autoclass:: UnicodeStringViolation | ||
| .. autoclass:: UnderscoredNumberViolation | ||
| .. autoclass:: PartialFloatViolation | ||
| .. autoclass:: FormattedStringViolation | ||
| .. autoclass:: ExplicitObjectBaseClassViolation | ||
| .. autoclass:: MultipleIfsInComprehensionViolation | ||
| .. autoclass:: ConstantCompareViolation | ||
| .. autoclass:: CompareOrderViolation | ||
| .. autoclass:: BadNumberSuffixViolation | ||
| .. autoclass:: MultipleInCompareViolation | ||
| .. autoclass:: UselessCompareViolation | ||
| .. autoclass:: MissingSpaceBetweenKeywordAndParenViolation | ||
| .. autoclass:: ConstantConditionViolation | ||
| .. autoclass:: ObjectInBaseClassesListViolation | ||
| .. autoclass:: MultipleContextManagerAssignmentsViolation | ||
| .. autoclass:: ParametersIndentationViolation | ||
| .. autoclass:: ExtraIndentationViolation | ||
| .. autoclass:: WrongBracketPositionViolation | ||
| .. autoclass:: MultilineFunctionAnnotationViolation | ||
| .. autoclass:: UppercaseStringModifierViolation | ||
| .. autoclass:: UselessMultilineStringViolation | ||
| .. autoclass:: ModuloStringFormatViolation | ||
| .. autoclass:: InconsistentReturnViolation | ||
| .. autoclass:: InconsistentYieldViolation | ||
| .. autoclass:: ImplicitStringConcatenationViolation | ||
| .. autoclass:: UselessContinueViolation | ||
| .. autoclass:: UselessNodeViolation | ||
| .. autoclass:: UselessExceptCaseViolation | ||
| .. autoclass:: UselessOperatorsViolation | ||
| .. autoclass:: InconsistentReturnVariableViolation | ||
| .. autoclass:: WalrusViolation | ||
| .. autoclass:: ImplicitComplexCompareViolation | ||
| .. autoclass:: ReversedComplexCompareViolation | ||
| .. autoclass:: WrongLoopIterTypeViolation | ||
| .. autoclass:: ExplicitStringConcatViolation | ||
| .. autoclass:: MultilineConditionsViolation | ||
| .. autoclass:: WrongMethodOrderViolation | ||
| .. autoclass:: NumberWithMeaninglessZeroViolation | ||
| .. autoclass:: PositiveExponentViolation | ||
| .. autoclass:: WrongHexNumberCaseViolation | ||
| .. autoclass:: ImplicitRawStringViolation | ||
| .. autoclass:: BadComplexNumberSuffixViolation | ||
| .. autoclass:: ZeroDivisionViolation | ||
| .. autoclass:: MeaninglessNumberOperationViolation | ||
| .. autoclass:: OperationSignNegationViolation | ||
| .. autoclass:: VagueImportViolation | ||
| .. autoclass:: LineStartsWithDotViolation | ||
| .. autoclass:: RedundantSubscriptViolation | ||
| .. autoclass:: AugmentedAssignPatternViolation | ||
| .. autoclass:: UnnecessaryLiteralsViolation | ||
| .. autoclass:: MultilineLoopViolation | ||
| .. autoclass:: IncorrectYieldFromTargetViolation | ||
| .. autoclass:: ConsecutiveYieldsViolation | ||
| .. autoclass:: BracketBlankLineViolation | ||
| .. autoclass:: IterableUnpackingViolation | ||
| .. autoclass:: LineCompriseCarriageReturnViolation | ||
| .. autoclass:: FloatZeroViolation | ||
| .. autoclass:: UnpackingIterableToListViolation | ||
| .. autoclass:: RawStringNotNeededViolation | ||
| .. autoclass:: InconsistentComprehensionViolation | ||
| .. autoclass:: AssignToSliceViolation | ||
| .. autoclass:: RaiseSystemExitViolation | ||
| """ | ||
@@ -161,0 +22,0 @@ |
@@ -123,55 +123,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| WrongModuleNameViolation | ||
| WrongModuleMagicNameViolation | ||
| WrongModuleNamePatternViolation | ||
| WrongVariableNameViolation | ||
| TooShortNameViolation | ||
| PrivateNameViolation | ||
| SameAliasImportViolation | ||
| UnderscoredNumberNameViolation | ||
| UpperCaseAttributeViolation | ||
| ConsecutiveUnderscoresInNameViolation | ||
| ReservedArgumentNameViolation | ||
| TooLongNameViolation | ||
| UnicodeNameViolation | ||
| TrailingUnderscoreViolation | ||
| UnusedVariableIsUsedViolation | ||
| UnusedVariableIsDefinedViolation | ||
| WrongUnusedVariableNameViolation | ||
| UnreadableNameViolation | ||
| BuiltinShadowingViolation | ||
| Module names | ||
| ------------ | ||
| .. autoclass:: WrongModuleNameViolation | ||
| .. autoclass:: WrongModuleMagicNameViolation | ||
| .. autoclass:: WrongModuleNamePatternViolation | ||
| General names | ||
| ------------- | ||
| .. autoclass:: WrongVariableNameViolation | ||
| .. autoclass:: TooShortNameViolation | ||
| .. autoclass:: PrivateNameViolation | ||
| .. autoclass:: SameAliasImportViolation | ||
| .. autoclass:: UnderscoredNumberNameViolation | ||
| .. autoclass:: UpperCaseAttributeViolation | ||
| .. autoclass:: ConsecutiveUnderscoresInNameViolation | ||
| .. autoclass:: ReservedArgumentNameViolation | ||
| .. autoclass:: TooLongNameViolation | ||
| .. autoclass:: UnicodeNameViolation | ||
| .. autoclass:: TrailingUnderscoreViolation | ||
| .. autoclass:: UnusedVariableIsUsedViolation | ||
| .. autoclass:: UnusedVariableIsDefinedViolation | ||
| .. autoclass:: WrongUnusedVariableNameViolation | ||
| .. autoclass:: UnreadableNameViolation | ||
| .. autoclass:: BuiltinShadowingViolation | ||
| """ | ||
@@ -505,2 +452,7 @@ | ||
| Configuration: | ||
| This rule is configurable with ``--known-enum-bases``. | ||
| Default: | ||
| :str:`wemake_python_styleguide.options.defaults.KNOWN_ENUM_BASES` | ||
| Example:: | ||
@@ -507,0 +459,0 @@ |
@@ -9,49 +9,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| BuiltinSubclassViolation | ||
| ShadowedClassAttributeViolation | ||
| StaticMethodViolation | ||
| BadMagicMethodViolation | ||
| WrongClassBodyContentViolation | ||
| MethodWithoutArgumentsViolation | ||
| WrongBaseClassViolation | ||
| WrongSlotsViolation | ||
| WrongSuperCallViolation | ||
| DirectMagicAttributeAccessViolation | ||
| AsyncMagicMethodViolation | ||
| YieldMagicMethodViolation | ||
| UselessOverwrittenMethodViolation | ||
| WrongSuperCallAccessViolation | ||
| WrongDescriptorDecoratorViolation | ||
| UnpythonicGetterSetterViolation | ||
| BuggySuperContextViolation | ||
| LambdaAttributeAssignedViolation | ||
| Respect your objects | ||
| -------------------- | ||
| .. autoclass:: BuiltinSubclassViolation | ||
| .. autoclass:: ShadowedClassAttributeViolation | ||
| .. autoclass:: StaticMethodViolation | ||
| .. autoclass:: BadMagicMethodViolation | ||
| .. autoclass:: WrongClassBodyContentViolation | ||
| .. autoclass:: MethodWithoutArgumentsViolation | ||
| .. autoclass:: WrongBaseClassViolation | ||
| .. autoclass:: WrongSlotsViolation | ||
| .. autoclass:: WrongSuperCallViolation | ||
| .. autoclass:: DirectMagicAttributeAccessViolation | ||
| .. autoclass:: AsyncMagicMethodViolation | ||
| .. autoclass:: YieldMagicMethodViolation | ||
| .. autoclass:: UselessOverwrittenMethodViolation | ||
| .. autoclass:: WrongSuperCallAccessViolation | ||
| .. autoclass:: WrongDescriptorDecoratorViolation | ||
| .. autoclass:: UnpythonicGetterSetterViolation | ||
| .. autoclass:: BuggySuperContextViolation | ||
| .. autoclass:: LambdaAttributeAssignedViolation | ||
| """ | ||
@@ -58,0 +11,0 @@ |
@@ -10,87 +10,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| UselessLoopElseViolation | ||
| UselessFinallyViolation | ||
| SimplifiableIfViolation | ||
| UselessReturningElseViolation | ||
| NegatedConditionsViolation | ||
| NestedTryViolation | ||
| UselessLambdaViolation | ||
| UselessLenCompareViolation | ||
| NotOperatorWithCompareViolation | ||
| NestedTernaryViolation | ||
| WrongInCompareTypeViolation | ||
| UnmergedIsinstanceCallsViolation | ||
| WrongIsinstanceWithTupleViolation | ||
| ImplicitElifViolation | ||
| ImplicitInConditionViolation | ||
| OpenWithoutContextManagerViolation | ||
| TypeCompareViolation | ||
| PointlessStarredViolation | ||
| ImplicitEnumerateViolation | ||
| ImplicitSumViolation | ||
| FalsyConstantCompareViolation | ||
| WrongIsCompareViolation | ||
| ImplicitPrimitiveViolation | ||
| AlmostSwappedViolation | ||
| MisrefactoredAssignmentViolation | ||
| InCompareWithSingleItemContainerViolation | ||
| ImplicitYieldFromViolation | ||
| NotATupleArgumentViolation | ||
| ImplicitItemsIteratorViolation | ||
| ImplicitDictGetViolation | ||
| ImplicitNegativeIndexViolation | ||
| SimplifiableReturningIfViolation | ||
| ChainedIsViolation | ||
| DuplicateIfConditionViolation | ||
| UselessTernaryViolation | ||
| DuplicateCasePatternViolation | ||
| ExtraMatchSubjectSyntaxViolation | ||
| Refactoring opportunities | ||
| ------------------------- | ||
| .. autoclass:: UselessLoopElseViolation | ||
| .. autoclass:: UselessFinallyViolation | ||
| .. autoclass:: SimplifiableIfViolation | ||
| .. autoclass:: UselessReturningElseViolation | ||
| .. autoclass:: NegatedConditionsViolation | ||
| .. autoclass:: NestedTryViolation | ||
| .. autoclass:: UselessLambdaViolation | ||
| .. autoclass:: UselessLenCompareViolation | ||
| .. autoclass:: NotOperatorWithCompareViolation | ||
| .. autoclass:: NestedTernaryViolation | ||
| .. autoclass:: WrongInCompareTypeViolation | ||
| .. autoclass:: UnmergedIsinstanceCallsViolation | ||
| .. autoclass:: WrongIsinstanceWithTupleViolation | ||
| .. autoclass:: ImplicitElifViolation | ||
| .. autoclass:: ImplicitInConditionViolation | ||
| .. autoclass:: OpenWithoutContextManagerViolation | ||
| .. autoclass:: TypeCompareViolation | ||
| .. autoclass:: PointlessStarredViolation | ||
| .. autoclass:: ImplicitEnumerateViolation | ||
| .. autoclass:: ImplicitSumViolation | ||
| .. autoclass:: FalsyConstantCompareViolation | ||
| .. autoclass:: WrongIsCompareViolation | ||
| .. autoclass:: ImplicitPrimitiveViolation | ||
| .. autoclass:: AlmostSwappedViolation | ||
| .. autoclass:: MisrefactoredAssignmentViolation | ||
| .. autoclass:: InCompareWithSingleItemContainerViolation | ||
| .. autoclass:: ImplicitYieldFromViolation | ||
| .. autoclass:: NotATupleArgumentViolation | ||
| .. autoclass:: ImplicitItemsIteratorViolation | ||
| .. autoclass:: ImplicitDictGetViolation | ||
| .. autoclass:: ImplicitNegativeIndexViolation | ||
| .. autoclass:: SimplifiableReturningIfViolation | ||
| .. autoclass:: ChainedIsViolation | ||
| .. autoclass:: DuplicateIfConditionViolation | ||
| .. autoclass:: UselessTernaryViolation | ||
| .. autoclass:: DuplicateCasePatternViolation | ||
| .. autoclass:: ExtraMatchSubjectSyntaxViolation | ||
| """ | ||
@@ -97,0 +12,0 @@ |
@@ -10,15 +10,2 @@ """ | ||
| Summary | ||
| ------- | ||
| .. autosummary:: | ||
| :nosignatures: | ||
| InternalErrorViolation | ||
| Respect your objects | ||
| -------------------- | ||
| .. autoclass:: InternalErrorViolation | ||
| """ | ||
@@ -25,0 +12,0 @@ |
@@ -64,2 +64,3 @@ import ast | ||
| """Forbids incorrect usage of strings.""" | ||
| assert isinstance(node.value, str | bytes) # for mypy # noqa: S101 | ||
| text_data = source.render_string(node.value) | ||
@@ -212,3 +213,5 @@ self._check_is_alphabet(node, text_data) | ||
| or check_is_node_in_specific_annotation( | ||
| parent, 'Literal', self._allowed_modules_to_literal_type_hint | ||
| parent, | ||
| 'Literal', | ||
| self._allowed_modules_to_literal_type_hint, | ||
| ) | ||
@@ -215,0 +218,0 @@ ): |
@@ -69,3 +69,4 @@ import ast | ||
| if isinstance( | ||
| attribute, ast.Attribute | ||
| attribute, | ||
| ast.Attribute, | ||
| ) and attributes.is_special_attr(attribute): | ||
@@ -72,0 +73,0 @@ self.add_violation(oop.LambdaAttributeAssignedViolation(node)) |
@@ -143,3 +143,4 @@ import ast | ||
| def visit_ClassDef( # pragma: >=3.13 cover | ||
| self, node: ast.ClassDef | ||
| self, | ||
| node: ast.ClassDef, | ||
| ) -> None: | ||
@@ -152,3 +153,4 @@ """Check class definition for violation.""" | ||
| def _check_generics( # pragma: >=3.13 cover | ||
| self, type_params: Sequence[ast.AST] | ||
| self, | ||
| type_params: Sequence[ast.AST], | ||
| ) -> None: | ||
@@ -163,3 +165,3 @@ had_default = False | ||
| self.add_violation( | ||
| SneakyTypeVarWithDefaultViolation(type_param) | ||
| SneakyTypeVarWithDefaultViolation(type_param), | ||
| ) |
@@ -107,3 +107,4 @@ import ast | ||
| if not super_args.is_ordinary_super_call( | ||
| attribute.value, class_name | ||
| attribute.value, | ||
| class_name, | ||
| ) or not function_args.is_call_matched_by_arguments(node, call_stmt): | ||
@@ -110,0 +111,0 @@ return |
@@ -104,3 +104,3 @@ import ast | ||
| conditions_count = self._count_conditions(node) | ||
| if conditions_count > constants.MAX_CONDITIONS: | ||
| if conditions_count > self.options.max_conditions: | ||
| self.add_violation( | ||
@@ -110,3 +110,3 @@ complexity.TooManyConditionsViolation( | ||
| text=str(conditions_count), | ||
| baseline=constants.MAX_CONDITIONS, | ||
| baseline=self.options.max_conditions, | ||
| ), | ||
@@ -242,3 +242,3 @@ ) | ||
| baseline=self.options.max_except_exceptions, | ||
| ) | ||
| ), | ||
| ) | ||
@@ -331,3 +331,3 @@ | ||
| baseline=self.options.max_type_params, | ||
| ) | ||
| ), | ||
| ) |
@@ -86,3 +86,6 @@ import ast | ||
| # they are overused. | ||
| if node.value in self._ignored_string_constants: | ||
| if ( | ||
| not isinstance(node.value, AnyTextPrimitive) | ||
| or node.value in self._ignored_string_constants | ||
| ): | ||
| return | ||
@@ -89,0 +92,0 @@ |
@@ -27,3 +27,3 @@ import ast | ||
| baseline=self.options.max_match_subjects, | ||
| ) | ||
| ), | ||
| ) | ||
@@ -30,0 +30,0 @@ |
@@ -79,3 +79,3 @@ import ast | ||
| text=condition, | ||
| ) | ||
| ), | ||
| ) | ||
@@ -171,3 +171,3 @@ | ||
| text=condition, | ||
| ) | ||
| ), | ||
| ) | ||
@@ -174,0 +174,0 @@ |
@@ -67,3 +67,4 @@ import ast | ||
| return attributes.only_consists_of_parts( | ||
| node, self.ALLOWED_DECORATOR_TYPES | ||
| node, | ||
| self.ALLOWED_DECORATOR_TYPES, | ||
| ) |
@@ -166,5 +166,6 @@ import ast | ||
| is_three_args_range = ( | ||
| self._is_multiple_args_range_with_len(node) | ||
| self._is_multiple_args_range_with_len(node) # noqa: WPS222 | ||
| and args_len == 3 | ||
| and isinstance(step_arg, ast.Constant) | ||
| and isinstance(step_arg.value, int | float) | ||
| and abs(step_arg.value) == 1 | ||
@@ -171,0 +172,0 @@ ) |
@@ -174,3 +174,4 @@ import ast | ||
| if isinstance(node, ast.Pass) and walk.get_closest_parent( | ||
| node, ast.match_case | ||
| node, | ||
| ast.match_case, | ||
| ): | ||
@@ -177,0 +178,0 @@ return # We allow `pass` in `match: case:` |
@@ -282,3 +282,4 @@ import ast | ||
| if isinstance(node_parent, ast.For) and self._is_node_in_loop_iter( | ||
| node, node_parent.iter | ||
| node, | ||
| node_parent.iter, | ||
| ): | ||
@@ -285,0 +286,0 @@ # await allowed in loop definition |
@@ -51,2 +51,9 @@ import ast | ||
| only_imports = all( | ||
| isinstance(statement, (ast.Import, ast.ImportFrom)) | ||
| for statement in node.body | ||
| ) | ||
| if only_imports: | ||
| return | ||
| if len(node.body) > 1: | ||
@@ -53,0 +60,0 @@ self.add_violation(InitModuleHasLogicViolation()) |
@@ -231,3 +231,3 @@ import ast | ||
| ) | ||
| is_enum_like = enums.has_enum_like_base(node) | ||
| is_enum_like = enums.has_enum_like_base_with_config(node, self._options) | ||
@@ -234,0 +234,0 @@ for assign in class_attributes: |
@@ -123,6 +123,6 @@ import ast | ||
| if ( | ||
| isinstance(left, ast.Constant) | ||
| right | ||
| and isinstance(left, ast.Constant) # noqa: WPS222 | ||
| and left.value in self._left_special_cases | ||
| and right | ||
| and isinstance(op, self._left_special_cases[left.value]) | ||
| and isinstance(op, self._left_special_cases[left.value]) # type: ignore[index] | ||
| ): | ||
@@ -134,3 +134,3 @@ left = None | ||
| for number in non_negative_numbers: | ||
| forbidden = self._meaningless_operations.get(number.value, None) | ||
| forbidden = self._meaningless_operations.get(number.value) # type: ignore[arg-type] | ||
| if forbidden and isinstance(op, forbidden): | ||
@@ -137,0 +137,0 @@ self.add_violation( |
@@ -187,3 +187,4 @@ import ast | ||
| return isinstance(real_node, ast.Constant) and isinstance( | ||
| real_node.value, float | ||
| real_node.value, | ||
| float, | ||
| ) | ||
@@ -216,3 +217,3 @@ | ||
| self.add_violation( | ||
| best_practices.NonStrictSliceOperationsViolation(node) | ||
| best_practices.NonStrictSliceOperationsViolation(node), | ||
| ) | ||
@@ -237,3 +238,3 @@ | ||
| self.add_violation( | ||
| best_practices.NonStrictSliceOperationsViolation(node) | ||
| best_practices.NonStrictSliceOperationsViolation(node), | ||
| ) | ||
@@ -247,3 +248,5 @@ | ||
| def _is_node_have_value( | ||
| self, node: ast.AST | None, value_to_check: int | ||
| self, | ||
| node: ast.AST | None, | ||
| value_to_check: int, | ||
| ) -> bool: | ||
@@ -250,0 +253,0 @@ if value_to_check < 0: |
@@ -307,3 +307,4 @@ """ | ||
| def from_checker( | ||
| cls: type['BaseNodeTokenVisitor'], checker | ||
| cls: type['BaseNodeTokenVisitor'], | ||
| checker, | ||
| ) -> 'BaseNodeTokenVisitor': | ||
@@ -310,0 +311,0 @@ """Constructs visitor instance from the checker.""" |
@@ -234,3 +234,3 @@ import re | ||
| class MultilineFormattedStringTokenVisitor( | ||
| BaseTokenVisitor | ||
| BaseTokenVisitor, | ||
| ): # pragma: >=3.12 cover | ||
@@ -237,0 +237,0 @@ """Checks incorrect formatted string usages.""" |
@@ -51,3 +51,3 @@ import tokenize | ||
| self.add_violation( | ||
| best_practices.WrongMultilineStringUseViolation(previous_token) | ||
| best_practices.WrongMultilineStringUseViolation(previous_token), | ||
| ) | ||
@@ -57,3 +57,3 @@ | ||
| self.add_violation( | ||
| best_practices.WrongMultilineStringUseViolation(next_token) | ||
| best_practices.WrongMultilineStringUseViolation(next_token), | ||
| ) | ||
@@ -60,0 +60,0 @@ |
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
670497
-2.47%17604
-2.67%