agronholm/typeguard

View on GitHub
src/typeguard/_functions.py

Summary

Maintainability
D
1 day
Test Coverage

Function check_multi_variable_assignment has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def check_multi_variable_assignment(
    value: Any, targets: list[dict[str, Any]], memo: TypeCheckMemo
) -> Any:
    if max(len(target) for target in targets) == 1:
        iterated_values = [value]
Severity: Minor
Found in src/typeguard/_functions.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File _functions.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

import sys
import warnings
from typing import Any, Callable, NoReturn, TypeVar, Union, overload
Severity: Minor
Found in src/typeguard/_functions.py - About 2 hrs to fix

    Function check_return_type has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_return_type(
        func_name: str,
        retval: T,
        annotation: Any,
        memo: TypeCheckMemo,
    Severity: Minor
    Found in src/typeguard/_functions.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function check_argument_types has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_argument_types(
        func_name: str,
        arguments: dict[str, tuple[Any, Any]],
        memo: TypeCheckMemo,
    ) -> Literal[True]:
    Severity: Minor
    Found in src/typeguard/_functions.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function check_send_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_send_type(
        func_name: str,
        sendval: T,
        annotation: Any,
        memo: TypeCheckMemo,
    Severity: Minor
    Found in src/typeguard/_functions.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function check_yield_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_yield_type(
        func_name: str,
        yieldval: T,
        annotation: Any,
        memo: TypeCheckMemo,
    Severity: Minor
    Found in src/typeguard/_functions.py - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function check_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def check_type(
    Severity: Minor
    Found in src/typeguard/_functions.py - About 45 mins to fix

      Function check_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def check_type(
      Severity: Minor
      Found in src/typeguard/_functions.py - About 45 mins to fix

        Function check_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def check_type(
        Severity: Minor
        Found in src/typeguard/_functions.py - About 45 mins to fix

          Function check_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def check_type(
              value: object,
              expected_type: Any,
              *,
              forward_ref_policy: ForwardRefPolicy = TypeCheckConfiguration().forward_ref_policy,
          Severity: Minor
          Found in src/typeguard/_functions.py - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          There are no issues that match your filters.

          Category
          Status