Showing 15 of 73 total issues
File configurator.py
has 499 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
The configurator registers routes in a FastAPI application while
adding support for dependency injection during the configuration phase.
FastAPI does not provide any built-in support for dependency injection
Function from_payload
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def from_payload(
cls, prefix: str, pydantic_type: type[T], data: Mapping[str, Any]
) -> "FormModel[T]":
try:
return cls(prefix, pydantic_type(**data.get(prefix, {})), {}, 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 unflatten_struct
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def unflatten_struct(
flatten_input: Mapping[str, Any],
unflattened_output: MutableMapping[str, Any] | MutableSequence[Any],
level: int = 0,
*,
- 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 __init__
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, client: "WebTestClient", origin: str, form: "Element"):
self._client = client
self._form = form
self._origin = origin
self._formfields: dict[str, Element] = {}
- 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_docstring
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def generate_docstring(
func_def: ast.FunctionDef, component_name: str, add_content: bool
) -> str:
"""Generate a docstring for a JinjaX component."""
# Extract function name and docstring
- 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 run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def run(self) -> list[nodes.Node]:
"""Generate structured and styled documentation for the directive."""
container_node = nodes.container(classes=["jinjax-component"])
# Extract the signature (first line of arguments)
- 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 iter_all_by_text
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def iter_all_by_text(
self, text: str, *, node_name: str | None = None
) -> "Iterator[Element]":
"""Return an iterator of all elements that match the text."""
nodes = self._tag.find_all(string=re.compile(rf"\s*{text}\s*"))
- 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 __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function as_def
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def as_def(self) -> ast.FunctionDef:
"""Return the component definition as a python function definition."""
signature = "def component(): pass"
match = RX_META_HEADER.match(self.source)
if match:
- 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 create_ref_node
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_ref_node(arg_type: str) -> nodes.Node:
"""
Creates a cross-reference node if a type has been inferred.
At the monent, type inferred are types containing a `.`, otherwise
- 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_widget
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_widget(
Avoid deeply nested control flow statements. Open
if is_union(typ):
args = typ.__args__
for arg in args:
if arg.__name__ == part:
typ = arg
Avoid deeply nested control flow statements. Open
if "selected" in option.attrs:
self._formdata[fieldname] = option.attrs.get(
"value", option.text
)
break
Function unflatten_struct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def unflatten_struct(
Function post
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def post(