Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/air/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 -----------------
Expand Down