Showing 23 of 23 total issues
Function add_schema
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def add_schema(
schema_name: str,
raw_schema: typing.Mapping[str, RawSchema],
schemas: typing.MutableMapping[str, Schema],
) -> Schema:
- Read upRead up
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 __new__
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def __new__(
cls,
name: str,
bases: typing.Tuple[type],
namespace: typing.Dict[str, object],
- Read upRead up
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 get_validator
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def get_validator(tp: object, *, model: typing.Optional[type] = None) -> AnnotationValidator:
"""Get a validator for the given type."""
# TODO: pydantic and dataclasses
if isinstance(tp, typing.TypeVar):
tp = resolve_typevar(tp, model=model)
- Read upRead up
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 format_field_type
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def format_field_type(
field: typing.Union[str, Field],
*,
python: typing.Optional[VersionInfo] = None,
) -> str:
- Read upRead up
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 resolve_typevars
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def resolve_typevars(cls: type) -> typing.Mapping[str, object]:
"""Resolve typevar names to types."""
typevars: typing.Mapping[str, object] = {}
orig_bases: typing.Sequence[typing.Any] = getattr(cls, "__orig_bases__", ())
- Read upRead up
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 join_mappings
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def join_mappings(mappings: typing.Sequence[typing.Mapping[str, T]]) -> typing.Mapping[str, tutils.MaybeTuple[T]]:
"""Join a sequence of mappings."""
output: typing.Mapping[str, tutils.MaybeTuple[T]] = {}
for index, mapping in enumerate(mappings):
for k, value in mapping.items():
- Read upRead up
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 flatten_errors
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def flatten_errors(
errors: typing.Sequence[ErrorList],
loc: typing.Optional[Loc] = None,
) -> typing.Iterator[typing.Tuple[Loc, Exception]]:
"""Flatten recursive errors."""
- Read upRead up
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 as_dict
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def as_dict(
self,
*,
private: bool = False,
properties: bool = True,
- Read upRead up
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 recognize_json_type
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def recognize_json_type(value: JSONType) -> RawSchema:
"""Recognize JSON type of value."""
if value in tutils.NoneTypes:
return "None"
- Read upRead up
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 collection_validator
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def collection_validator(
collection_type: typing.Callable[[typing.Collection[typing.Any]], typing.Collection[object]],
inner_validator: validation.Validator,
) -> AnnotationValidator:
"""Validate the items of a collection."""
- Read upRead up
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 debuggable_deco
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def debuggable_deco(func: tutils.CallableT) -> tutils.CallableT:
"""Make a higher order function's return debuggable."""
def wrapper(*args: object, **kwargs: object) -> object:
obj = func(*args, **kwargs)
- Read upRead up
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
Avoid deeply nested control flow statements. Open
with catcher.catch(loc=attr_name):
obj[attr_name] = await validator(instance, obj[attr_name])
setattr(instance, attr_name, obj[attr_name])
# =============================
Function tuple_validator
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def tuple_validator(tup: typing.Type[typing.Tuple[object, ...]]) -> AnnotationValidator:
"""Validate a namedtuple."""
if hasattr(tup, "_fields"):
name = tup.__name__
types = getattr(tup, "_field_types", {}) or getattr(tup, "__annotations__", {})
- Read upRead up
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 generate_models
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def generate_models(
data: JSONType,
*,
python: typing.Optional[VersionInfo] = None,
) -> str:
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if not isinstance(x, str):
raise ValueError("Found nesting in the raw schema.")
Function resolve_typevar
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def resolve_typevar(tp: typing.TypeVar, *, model: typing.Optional[type] = None) -> object:
if model is not None:
typevars = utility.resolve_typevars(model)
if tp.__name__ not in typevars:
raise TypeError(f"Undeclared typevar used: {tp}")
- Read upRead up
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 __getattribute__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __getattribute__(self, name: str) -> typing.Any:
"""Optimize directly getting asynchronous."""
if name in ("synchronous", "asynchronous"):
isasync = asyncio.iscoroutinefunction(self.callback)
if name == "synchronous" and not isasync and "async" not in self.callback.__name__:
- Read upRead up
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 skip_member
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def skip_member(
app: sphinx.application.Sphinx,
what: typing.Literal["attribute", "class", "data", "exception", "function", "method", "module", "package"],
name: str,
obj: autoapi_objects.PythonPythonMapper,
- Read upRead up
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 from_annotation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def from_annotation(
cls,
name: str,
annotation: object,
default: object = ...,
- Read upRead up
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 union_validator
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def union_validator(*validators: validation.Validator) -> AnnotationValidator:
"""Return the first successful validator."""
if len(validators) == 1:
validator = validators[0]
if isinstance(validator, AnnotationValidator):
- Read upRead up
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"