diff --git a/ruff.toml b/ruff.toml index 56b525888..ff9e86c1f 100644 --- a/ruff.toml +++ b/ruff.toml @@ -104,11 +104,13 @@ select = [ "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try ] +extend-select = [ + "D105", # undocumented-magic-method +] ignore = [ "D100", # ignore missing docstring in module "D102", # ignore missing docstring in public method "D104", # ignore missing docstring in public package - "D105", # ignore missing docstring in magic methods "D107", # ignore missing docstring in __init__ methods "D206", # docstring-tab-indentation (formatter handles indentation) "D300", # triple-single-quotes (formatter enforces double quotes) diff --git a/src/air/requests.py b/src/air/requests.py index eed82083d..15be04946 100644 --- a/src/air/requests.py +++ b/src/air/requests.py @@ -82,6 +82,8 @@ def index(request: air.Request): triggering_event: Any = field(init=False) def __post_init__(self) -> None: + """Perform the calculation and initialization of fields based on HTMX headers.""" + self.is_hx_request = self.headers.get(HX_REQUEST) == "true" self.boosted = self.headers.get(HX_BOOSTED) == "true" @@ -137,6 +139,7 @@ def index(request: air.Request): return self.headers.get("HX-Request") == "true" def __str__(self) -> str: + """Return the string representation of the HX-Request header.""" return str(self.__bool__()) # ----------------- Private helpers -----------------