diff --git a/examples/django/datastar/asgi.py b/examples/django/datastar/asgi.py index 73df6db..d63624b 100644 --- a/examples/django/datastar/asgi.py +++ b/examples/django/datastar/asgi.py @@ -1,5 +1,4 @@ -""" -ASGI config for datastar project. +"""ASGI config for datastar project. It exposes the ASGI callable as a module-level variable named ``application``. diff --git a/examples/django/datastar/settings.py b/examples/django/datastar/settings.py index f9ce457..de4088c 100644 --- a/examples/django/datastar/settings.py +++ b/examples/django/datastar/settings.py @@ -1,5 +1,4 @@ -""" -Django settings for datastar project. +"""Django settings for datastar project. Generated by 'django-admin startproject' using Django 4.2.16. diff --git a/examples/django/datastar/urls.py b/examples/django/datastar/urls.py index 0f163cc..03ca92e 100644 --- a/examples/django/datastar/urls.py +++ b/examples/django/datastar/urls.py @@ -1,8 +1,8 @@ -""" -URL configuration for datastar project. +"""URL configuration for datastar project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ + Examples: Function views 1. Add an import: from my_app import views @@ -13,6 +13,7 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) + """ from django.contrib import admin diff --git a/examples/django/datastar/wsgi.py b/examples/django/datastar/wsgi.py index 1257b86..ee2f6ca 100644 --- a/examples/django/datastar/wsgi.py +++ b/examples/django/datastar/wsgi.py @@ -1,5 +1,4 @@ -""" -WSGI config for datastar project. +"""WSGI config for datastar project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -20,7 +19,7 @@ original_is_hop_by_hop = wsgiref.handlers.is_hop_by_hop def custom_is_hop_by_hop(header_name): - """Permit the "connection" header over WSGI + """Permit the "connection" header over WSGI. Datastar by default, sets the connection header to "keep-alive". Per the WSGI spec (see below), wsgiref does not permit setting diff --git a/pyproject.toml b/pyproject.toml index 24e3aaf..adff4e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ lint.select = [ "ANN", # flake8-bugbear "B", + "D", # pycodestyle "E", # Pyflakes @@ -70,7 +71,19 @@ lint.select = [ # pyupgrade "UP", ] -lint.ignore = [ "E501" ] +lint.ignore = [ + "D100", # undocumented-public-module + "D101", # undocumented-public-class + "D102", # undocumented-public-method + "D103", # undocumented-public-function + "D104", # undocumented-public-package + "D107", # undocumented-public-init + "D203", # Conflicting with other rules + "D213", # Conflicting with other rules + "D401", # non-imperative-mood + "D415", # Duplicate of D400 + "E501", +] lint.fixable = [ "ALL" ] per-file-ignores."examples/**/*.py" = [ "ANN" ] diff --git a/sdk-test.py b/sdk-test.py index 7e22c77..36cdf7c 100644 --- a/sdk-test.py +++ b/sdk-test.py @@ -8,8 +8,8 @@ # datastar-py = { path = "." } # /// -""" -Runs a test server that the SDK tests can be run against. +"""Runs a test server that the SDK tests can be run against. + 1. Start this server with `uv run sdk-test.py` 2. Move to the sdk/tests folder. 3. Run `test-all.sh http://127.0.0.1:8000` to run the tests. diff --git a/src/datastar_py/attributes.py b/src/datastar_py/attributes.py index 4b043a3..3263c11 100644 --- a/src/datastar_py/attributes.py +++ b/src/datastar_py/attributes.py @@ -257,7 +257,7 @@ def show(self, expression: str) -> BaseAttr: return BaseAttr("show", value=expression, alias=self._alias) def style(self, style_dict: Mapping | None = None, /, **styles: str) -> BaseAttr: - """Sets the value of inline CSS styles on an element based on an expression, and keeps them in sync.""" + """Set the value of inline CSS styles on an element based on an expression, and keeps them in sync.""" styles = {**(style_dict if style_dict else {}), **styles} return BaseAttr("style", value=_js_object(styles), alias=self._alias) diff --git a/src/datastar_py/django.py b/src/datastar_py/django.py index c1b88fb..1c14b92 100644 --- a/src/datastar_py/django.py +++ b/src/datastar_py/django.py @@ -19,7 +19,7 @@ class DatastarResponse(_StreamingHttpResponse): - """Respond with 0..N `DatastarEvent`s""" + """Respond with 0..N `DatastarEvent`s.""" default_headers: dict[str, str] = SSE_HEADERS.copy() diff --git a/src/datastar_py/litestar.py b/src/datastar_py/litestar.py index dbccf4c..97a3a5f 100644 --- a/src/datastar_py/litestar.py +++ b/src/datastar_py/litestar.py @@ -28,7 +28,7 @@ class DatastarResponse(Stream): - """Respond with 0..N `DatastarEvent`s""" + """Respond with 0..N `DatastarEvent`s.""" default_headers: dict[str, str] = SSE_HEADERS.copy() diff --git a/src/datastar_py/quart.py b/src/datastar_py/quart.py index b0680bb..90c3cb4 100644 --- a/src/datastar_py/quart.py +++ b/src/datastar_py/quart.py @@ -19,7 +19,7 @@ class DatastarResponse(Response): - """Respond with 0..N `DatastarEvent`s""" + """Respond with 0..N `DatastarEvent`s.""" default_headers: dict[str, str] = SSE_HEADERS.copy() diff --git a/src/datastar_py/sse.py b/src/datastar_py/sse.py index 8466845..4cc35e4 100644 --- a/src/datastar_py/sse.py +++ b/src/datastar_py/sse.py @@ -21,7 +21,8 @@ class _HtmlProvider(Protocol): This is a convention used by html producing/consuming libraries. This lets e.g. fasthtml fasttags, or htpy elements, be passed straight in to - merge_fragments.""" + merge_fragments. + """ def __html__(self) -> str: ... diff --git a/src/datastar_py/starlette.py b/src/datastar_py/starlette.py index 5d072f9..53989af 100644 --- a/src/datastar_py/starlette.py +++ b/src/datastar_py/starlette.py @@ -27,7 +27,7 @@ class DatastarResponse(_StreamingResponse): - """Respond with 0..N `DatastarEvent`s""" + """Respond with 0..N `DatastarEvent`s.""" default_headers: dict[str, str] = SSE_HEADERS.copy()