Release Notes¶
0.22.8¶
Added¶
- Add
SimpleFileResponseand internalDispositionResponse.
Changed¶
- Improved dependency resolution logic to refine request injection rules.
- Enhanced
Provideto handle nested dependency injection with stricter argument checks. - Updated precedence handling to ensure consistent dependency resolution order across async libraries.
- Improved Responses:
- StreamingResponse eliminates one round-trip.
- Response has deduction capabilities of the media-type (python-magic required).
- ImageResponse is now an alias of
SimpleFileResponse. - Make
CSVResponseandNDJSONResponsestreaming. send_fileuses nowSimpleFileResponse.
Fixed¶
- Request objects were being injected into zero-argument dependencies.
- Dependency injection precedence edge cases between global and route-level dependencies.
- Fix
BaseSettingsfor python 3.14 and more complex inheritances.
0.22.7¶
Changed¶
- Improved the internals of the shell when loading.
Fixed¶
- Encoders were overriding values stripping forbidden values. Evaluation is now done on the whole json.
0.22.6¶
Fixed¶
- Fix 502 Gateway timeout when using
EventStreamResponsewith long-lived connections.
0.22.5¶
Added¶
- Support for dependency overrides. This allows you to override dependencies globally in the application or in specific includes. This is particularly useful for testing and mocking dependencies.
Changed¶
EnvironLoadernow support native YAML files.- Environments documentation section with examples and usage.
Fixed¶
- Fixed
EventStreamResponseerror message to display in seconds and not milliseconds.
0.22.4¶
This was missed from the 0.22.3 release.
Fixed¶
- Fixed
EventStreamResponsewhen it was not establishing the connection properly.
0.22.3¶
Added¶
runserver_themetoLilyasettings andrunserverdirective. This allows you to customise the theme of thelilya runservercommand.
Fixed¶
- Regression in runserver with a path provided.
0.22.2¶
Added¶
- Support for multiple cookie headers in the
Requestobject. This follows the RFC 7540.
Changed¶
- Core implementation for EventStreamResponse to support multiple headers and parameters.
0.22.1¶
Changed¶
- Lilya
requiresnow accepts a parameter for custom connection name checking and removes the enforcing of the connection name to be None. - Extend the
authenticatesignature with extra kwargs forlilay.authentication.AuthenticationBackend.
Fixed¶
- Documentation typos.
0.22.0¶
Added¶
- New Lifecycle system allowing to create global and app level lifecycle hooks. With more explanatory documentation.
- Dependency Scopes — Introduced a flexible scoping system for dependency lifetimes.
Scope.REQUEST: Default per-request lifetime.Scope.APP: Application-wide shared dependencies.Scope.GLOBAL: Process-level shared instances.
- New security SignedURL utility for generating and verifying time-limited signed URLs.
- New SSEChannel class for creating in-memory Server-Sent Events channels with pub/sub support.
New Responses¶
- CSVResponse as a new available response for CSV files directly in the
lilya.responses. - YAMLResponse as a new available response for YAML files directly in the
lilya.responses. - XMLResponse as a new available response for XML files directly in the
lilya.responses. - MessagePackResponse as a new available response for MessagePack files directly in the
lilya.responses. - NDJSONResponse as a new available response for Newline Delimited JSON files directly in the
lilya.responses. - ImageResponse as a new available response for images directly in the
lilya.responses. TextResponseas a new available response for plain text files directly in thelilya.responses.- EventStreamResponse as a new available response for Server-Sent Events directly in the
lilya.responses.
Fixed¶
- CompactSerializer was not overriding kwargs properly.
0.21.1¶
Added¶
- OpenTelemetry integration under
lilya.contrib.opentelemetry: - Introduced
OpenTelemetryMiddlewarefor automatic request tracing.- Creates one
SERVERspan per HTTP request. - Records standard HTTP attributes (
method,path,status,client.address,url.query, etc.). - Captures exceptions and marks spans with
StatusCode.ERROR. - Handles parent context extraction from inbound headers for trace propagation.
- Creates one
- Added
setup_tracing(config: OpenTelemetryConfig | None)helper.- Initializes a global
TracerProviderwith aBatchSpanProcessor. - Automatically selects between
ConsoleSpanExporter,OTLP/gRPC, andOTLP/HTTPexporters. - Safe to call multiple times (idempotent).
- Initializes a global
- Added
OpenTelemetryConfigdataclass for configuration.- Supports fields:
service_name: logical name reported to telemetry backends.exporter:"otlp"or"console".otlp_endpoint: e.g."http://localhost:4317"or"http://collector:4318".otlp_insecure: disable TLS verification for gRPC exporters.sampler:"parentbased_always_on","always_on", or"always_off".
- Added
get_tracer_provider()utility to retrieve the activeTracerProvider. - Async testing utilities:
- Introduced AsyncTestClient and create_async_client() to allow fully asynchronous testing of Lilya apps.
- Both support full middleware stacks, including
OpenTelemetryMiddleware. - Enables concurrent request tests and real async span creation with in-memory exporters.
- Contrib Shortcuts:
- New abort function to raise HTTP exceptions.
- New responses shorcuts including:
send_json(): send JSON responses with proper headers.json_error(): send JSON error responses with status codes.stream(): stream response content from async generators.empty(): return empty 204 No Content responses.redirect(): send HTTP redirects with proper status codes and headers.forbidden(): send 403 Forbidden responses.not_found(): send 404 Not Found responses.unauthorized(): send 401 Unauthorized responses.
Changed¶
redirectnow is inlilya.contrib.responses.shortcuts.
Fixed¶
send_filenow correctly setsContent-Dispositionheaders for file downloads.- Late binding in the
make_response.
0.21.0¶
Added¶
- Python 3.14 support.
0.20.10¶
Fixed¶
- Validation
upper()was not being applied properly in the csrf token.
0.20.9¶
This was supposed to go in the version 0.20.8 and it was forgotten.
Added¶
__exclude_from_openapi__Added to the base controller allowing the exclusion from the BaseTemplates.
Changed¶
- Lilya create project default was still using an old version of the generator.
Fixed¶
- OpenAPI documentation was not excluding templating system and statics.
0.20.8¶
Added¶
itsdangerousto requirementsallandstandard.
Changed¶
@directive(display_in_cli=True)discovery improved by showing errors and not throw directly an exception.- Update minimum Sayer version to 0.6.0.
- Custom directives under
@directiveare now displayed in a "Custom directives" group.
0.20.7¶
Added¶
csrf_token_nameas new parameter in the Lilya settings. This will allow you to globally set the name of thecsrftoken when using CSRFMiddleware.csrf_enabledflag toTemplateController. This will automatically inject thecsrftoken in the context of the templates.csrf_token_form_nametoTemplateController. This defaults tocsrf_tokenand corresponds to the name of the variable that is injected in the context of the template for the CSRF token whencsrf_enabled.- Support for
@directiveto be display when callinglilyaclient. - display_in_cli to
@directive.
Changed¶
- Make
responseoptional in theget_or_set_csrf_token.
Removed¶
- Wrong example for the CSRF token in the security with CSRF.
0.20.6¶
Added¶
- Relay. This allows to create objects that are ASGI compatible and upstream services within your Lilya application.
- WebSocket proxying: Added full support for bidirectional WS proxying (text + binary frames).
- Retry & backoff: Configurable retry logic with exponential backoff on retryable statuses/exceptions.
- Timeout mapping: Upstream timeouts now map to
504 Gateway Timeout. - Header policies: Added support for allow-list mode (
allow_request_headers,allow_response_headers) in addition to drop-lists. - Structured logging: Proxy events (
upstream_error,upstream_timeout,upstream_retryable_error) now emit consistent log messages for observability. - Support for CSRFMiddleware to understand the HTML forms allowing also custom fields.
- New HTML response as an alternative to
HTMLResponse. - New documentation section for security with CSRF.
Changed¶
- Added
python-multipartas part of theallandstandardLilya packages. - Replaced
python-multipartwith a fully native multipart, urlencoded, and octet-stream form parser. - Improved RFC 5987 parameter decoding for proper handling of UTF-8 filenames and headers.
AuthenticationErrorexception is now located inlilya.exceptions.
0.20.5¶
This was a change for the newer sayer 0.5.1 that affects the client.
Changed¶
- Allow minimum Sayer to be 0.5.1.
- Lilya cli now loses the
nameargument. This is now handled directly by the newest Sayer that was internal refactored for the@callback.
0.20.4¶
Changed¶
- Update sayer dependency version to 0.5.0 and pin it.
0.20.3¶
Added¶
ValidationErroradded tolilya.exceptions.- Introduced lilya.contrib.mail providing a full-featured, async-first email framework.
- Includes a high-level
MailerAPI for sending single, multiple, and templated messages. - Supports multipart messages (text + HTML), custom headers, attachments (in-memory or files), and metadata.
- CLI integration,
lilya mail sendtest, for sending quick test emails via console backend.
Built-in Backends¶
- SMTPBackend: Async-friendly with connection pooling and TLS/authentication.
- ConsoleBackend: Writes messages to stdout for debugging.
- FileBackend: Saves emails as
.emlfiles for inspection or archiving. - InMemoryBackend: Stores emails in memory for development or testing scenarios.
Email Templates¶
- Added
TemplateRendererwith Jinja2 integration. send_templategenerates HTML + auto text fallbacks.- Supports separate text/HTML templates and contextual rendering.
Application Integration¶
- New
setup_mail(app, backend, template_dir, attach_lifecycle=True)utility attaches aMailertoapp.state.mailer. - Automatically opens/closes backend connections via startup/shutdown hooks.
Exception Hierarchy¶
MailError: Base exception for all mail errors.BackendNotConfigured: Raised when no backend or template renderer is configured.InvalidMessage: Raised when anEmailMessageis incomplete or malformed.
0.20.2¶
Added¶
is_jsonandis_formproperties forRequest.- Support for automatic body inference from forms (application/x-www-form-urlencoded and multipart/form-data), in addition to JSON.
- Complex types with collections, lists, sets, dicts supported by
infer_bodyas True. - File uploads (UploadFile and list[UploadFile]) are now seamlessly supported in body inference.
- Introduced dotted key expansion
(user.name=lilya)and bracket list notation(items[0].sku=test)to express nested objects and lists in form submissions. - New FormController class based view template that is agnostic to any validation library.
Changed¶
- Inferred body to allow the form request to be parsed properly.
- Improved typed structuring: collections like list[Item], tuple[Item, ...], dict[str, Item], and sets are now properly inferred and converted into typed objects.
0.20.1¶
Added¶
Changed¶
- Morph path argument into path option and expose it for all commands.
- Add
wrap_dependencyfor inherited Controller dependencies.
Fixed¶
- Properly detect wrapped Lilya instances.
- Fix crash in show-urls.
- Fix double initialization of app in runserver.
Breaking¶
- lilya runserver loses its path argument. You can specify it via
lilya --path foo runserver.
0.20.0¶
Added¶
- New request‑agnostic Depends for DI anywhere (sync/async, nested deps, overrides, per‑instance caching).
- Added @inject decorator to auto‑resolve
Dependson call. This preserves signature and honors explicit args.
Example¶
from lilya.dependencies import Depends, inject
def get_db():
session = Sessionlocal()
try:
yield session
finally:
session.close()
@inject
def get_db_session(db = Depends(get_db)) -> Any:
return db
0.19.8¶
Added¶
- Allow using
strashandlerparam for thePathandWebsocketPathas alternative.
Changed¶
RedirectResponsedefault from 307 toHTTP_303_SEE_OTHER.
Fixed¶
- Runserver when no autodiscovery was enabled.
- Initial settings was not initialising properly in the constructor.
- Edgy template was being wrongly renamed.
0.19.7¶
Added¶
- Compact json for the serializers.
Fixed¶
Queryparsing was overriding the default.
Changed¶
Encodersuse the nativelilya.serializers.serializerobject instead of directjson.
0.19.6¶
Added¶
--versionattribute when runningcreateappdirective allowing to generate a versioned scaffold.--locationattribute when usingcreateappandcreateprojectdirective allowing to specify the location to be created.--edgyattribute tocreateprojectallowing the generation of project scaffolds integrating Edgy ORM.exceptionmethod to logging protocol.wrap_dependencyinternal that will create aProvidein case a dependency is passed and noProvideis provided.- Add
Jinja2Templatesas alias toJinja2Template. - New dynamic, native and fast custom serializers.
Changed¶
- To make Lilya cleaner in the installation we have now separated the installation. The Lilya native client requires some additional packages and not everyone requires this or even desires but for those already using, the change is simple.
Before¶
$ pip install lilya
After¶
$ pip install lilya[standard]
This brings the current behaviour of Lilya prior to version 0.19.6 and nothing changes.
0.19.5¶
Fixed¶
- Allow string representation of bool in type check
0.19.4¶
Added¶
- Support for automatic cast call for a function is a function is provided to cast in the
loaderof the Environment. UUIDEncoderas a native for parsingUUIDtypes.TimedeltaEncoderas native encoder.
Fixed¶
- Fixed
@cachewhen decorating Class controllers and function controllers. - Permissions were not properly applied on
Controllertype objects. - Permissions protocol to check for the
__is_contoller__. - Documentation references.
Querywas not casting properly boolean values.
0.19.3¶
- Permission call order was reversed when called from within an Include, Path, Websocket and internal routing.
0.19.2¶
Fixed¶
- Nested dependencies where checking values that were not in the signature of the dependency itself.
0.19.1¶
Changed¶
- Root path for auto detection behind reverse proxies.
Fixed¶
- Typo in the error for the security.
- Servers for
openapiwere not being detected automatically.
0.19.0¶
Added¶
- Contrib security. This contrib is entirely optional and you don't need to use it but is served as an alternative to allow you to use Lilya security out of the box.
Fixed¶
- Nested dependencies that require internal parameters.
- Internals and refactor the OpenAPI spec to match the missing internals.
Changed¶
- Refactor the
@openapigenerator for security and authorization.
0.18.3¶
Added¶
- Lilya being agnostic to everything still has a contrib to integrate with the whole ecosystem so a native AsyncZ was added to support that same integration in a clean fashion.
- New
Contribsection in the documentation to make it clear the separation of concerns.
0.18.2¶
Added¶
-
Added support for
Queryparameter markers.- Implemented
aliassupport for query parameters to map custom keys. - Introduced
castfield inQueryfor runtime type coercion with validation. - Improved error handling for missing and invalid query parameter types.
- Implemented
-
Introduced
HeaderandCookieparameter markers withvalue,required, andcastsupport. - Expanded documentation into a comprehensive “Request Parameters” guide covering declaration, options, and real-world examples for all three types.
0.18.1¶
Changed¶
- Update directives to reflect the new settings.
Fixed¶
- Cache dependency on
jsonnative library.
0.18.0¶
Added¶
- Support for native cache with default to
InMemory. - Add support for relative urls from the
URLdatastructure. - Support for OpenAPI on Controllers by applying internal identity descriptors.
Changed¶
In the past, Lilya was using dataclass to manage all the settings but we found out that can be a bit combersome for a lot
of people that are more used to slighly cleaner interfaces and therefore, the internal API was updated to stop using @dataclass and
use directly a typed Settings object.
- Replace
Settingsto stop using@dataclassand start using direct objects instead.
Example before
from dataclasses import dataclass, field
from lilya.conf.global_settings import Settings
@dataclass
class MyCustomSettings(Settings):
hosts: list[str] = field(default_factory=lambda: ["example.com"])
Example after
from lilya.conf.global_settings import Settings
class MyCustomSettings(Settings):
hosts: list[str] = ["example.com"]
This makes the code cleaner and readable.
- Apply AnyIO to
DataUploadinstead of using BinaryIO.
0.17.1¶
Changed¶
- Dual‑mode support in run_sync: Now accepts either an async function with args or a standalone coroutine object.
- Input normalization: Uses
inspectto detect and wrap calls into a zero‑argument coroutine factory. - Seamless execution: Drives work on the main thread via
anyio.run, with a clean fallback toThreadPoolExecutorif an event loop is active. - Error clarity: Raises a precise
TypeErrorwhen the argument is neither a coroutine function nor object. - Simplified API: Eliminates nested lambdas by centralizing logic into a single
wrapper_fnpassed toanyio.run.
0.17.0¶
Added¶
- Missing validation that was supposed to go on the version 0.16.10 and it was not pushed.
Changed¶
- Mark
http_exceptionin theExceptionasasyncto avoid thread creation. - Replace
asyncio.iscoroutinefunctionwithinspect.iscoroutinefunction. - Replace
asyncioinrun_syncwith anyio. - Refactor
run_syncfromlilya.compat.
0.16.10¶
Fixed¶
infer_bodywith complex dependencies and path params evaluation wheninfer_body=True
0.16.9¶
Changed¶
- Unify dependency injection logic for both Controller and handlers.
- Unify logic for body inferring for Controller and handlers.
0.16.8¶
Added¶
- Add support for multi-byterange requests and responses.
- Add retro-compatibility for
path_forwith an aliasurl_for. This allows easier integration with other libraries that useurl_foras the method to generate URLs.
Changed¶
- Add
lru_cacheto some of the methods that are used to generate URLs. This allows for better performance when generating URLs that are frequently used. - Automatic Generator Unwrapping:
Provideandasync_resolve_dependenciesnow detect both sync and async generator dependencies, advance them to yield the real return value, and inject that into handlers.
0.16.7¶
Note
There was a part of the commit that was not properly pushed and this could cause inconsistencies and therefore a quick small release was done.
Changed¶
- Dependencies with
infer_bodyconsistency check.
0.16.6¶
Added¶
- Lilya
rundirective now injects thegglobal context for usage in the directives in offline mode. - Support for http ranges (bytes).
- Support if-range header.
- Added fallback dependency injection: Handlers can now receive dependencies even without explicitly using
Provides(), as long as they are defined in the app or route. - Improved optional injection logic: Dependencies declared with
Provides()are treated as required, while others are injected only if available—ensuring flexibility and safety. - Unified behavior across HTTP and WebSocket handlers: Dependency resolution logic now consistently supports both explicit and fallback injection in all handler types.
Changed¶
- Don't execute stream or analyze file for options for FileResponse, StreamingResponse. It is certainly unwanted and expensive.
- Don't execute background tasks for options and head. This is certainly unwanted.
- Add
allow_range_requestsparameter toFileResponsefor allowing to disable http range serving. - Deprecate the undocumented
methodparameter. It has no effect anymore. We infer it correctly from scope.
Fixed¶
- FileResponse and StreamResponse can deduce from scope headers if the request is headless.
0.16.5¶
Added¶
- Possibility and alternative way of doing the dependencies without the need of using the
Provides(). TheProvideis always required.
0.16.4¶
Changed¶
- Allow providing
notify_fnas string.
Fixed¶
- Fix missing default for
notify_fninSessionFixingMiddleware. - Re-add missing dependency
monkay. - Fix dependency to
typing-extensionsfor python>=3.11.
0.16.3¶
Changed¶
- Move
dependenciesfrom settings to a property based.
Fixed¶
- OpenAPIResponse
modelparameters as list.
0.16.2¶
Added¶
- Missing
dependenciesin the settings. - Missing
dependenciesin thecreate_client. - Add
TrustedReferrerMiddleware. - Add
SessionFixingMiddleware. - Add
ClientIPScopeOnlyMiddleware(splitted fromClientIPMiddleware). - Docs concerning security.
Changed¶
- Add
block_untrusted_hostsparameter toTrustedHostMiddleware.
Fixed¶
- When adding encoders dependencies with
infer_bodyas true, it was not filtering the body params properly.
0.16.1¶
Added¶
- Resolve dependency injection functionality. This resolve acts with the
ProviderandProvidesas well as a standalone operator. This aims to only to provide an alternative to the already powerful native dependency injection system of Lilya.
0.16.0¶
Added¶
-
Dependency Injection API
-
Introduced
Provide/Providespair for declarative DI on handlers -
Support for three layers of dependencies:
- Application-level – global services (e.g. database, feature flags)
- Include-level – sub-application scoping (e.g. per-module configs)
- Route-level – fine-grained overrides for specific endpoints
-
Handler Parameter Injection
- Automatically resolves
Provides()parameters by name - Supports async and sync factory functions
- Factory chaining: one provider may declare dependencies on another
- Automatically resolves
-
Per-Request Caching
Provide(..., use_cache=True)option to memoize within a request
-
WebSocket Support
- Inject dependencies into WS routes via the same
Provides()mechanism
- Inject dependencies into WS routes via the same
Changed¶
-
Scope Handling Fixes
- Stabilized
request.scope["app"]availability across HTTP, WS, and lifespan events
- Stabilized
-
Serialization Improvements
- Ensured
Provides()defaults aren't accidentally passed to JSON encoders
- Ensured
Fixed¶
- Fixed KeyError: 'app' in legacy routing tests when mounting nested includes
- Corrected nested factory resolution so upstream dependencies are auto-wired
0.15.6¶
Added¶
- Missing
before_requestandafter_requesttoapp.include. pathto runserver allowing the user to customise the path location of a Lilya app.- New
LilyaExceptionMiddlewarethat intercepts globally any exception that is not only from the handlers. This can be useful if you want to raise an exception in middlewares and be caught by the exception handlers declared. You need to also pass aenable_intercept_global_exceptionsin theLilyainstance or settings as this is disabled by default.
Changed¶
- Make
reloadin the runserverFalseby default. - Logging configuration can jump the
configureif necessary.
0.15.5¶
Added¶
- Support for multiplexing a session into multiple session contexts.
- Added support for
redirect_exceptionwhen using WSGIMiddleware. This flag when passed, you can add aHTTPExceptionexception handler that will make Lilya capture the WSGI exceptions. - Exception handlers on a global level can now be passed via settings
Changed¶
SessionContexthas now the methodsset_session,get_session. No moreget/set_connectionis used.infer_bodyis more assertive in the error messages.
Fixed¶
- Raise proper error when hitting the
inferredbody instead of a broad complicated message.
0.15.4¶
Added¶
- Support for a second form of declaring directives.
- Support for
@directivedecorator on top of a Sayer command making it a directive as long as it still follows the directive lookup for files.
Fixed¶
- Internal definitions and client optimisations.
0.15.3¶
Added¶
- Added optional
infer_bodyinto the settings. This will allow you to do something like this:
from msgspec import Struct
from pydantic import BaseModel
class User(BaseModel):
name: str
age: int
class Item(Struct):
sku: str
async def process_body(user: User, item: Item):
return {**user.model_dump(), "sku": item.sku}
Where the payload is:
{
"user": {"name": "lilya", "age": 20},
"item": {"sku": "test"}
}
Assuming you have the encoders for Pydantic and Struct installed in your application (or any other) you desire.
Lilya uses the internal Encoders to parse and transform them properly.
Note
infer_body is set to False by default but you can override it in the settings.
Another example can be:
from pydantic import BaseModel
class User(BaseModel):
name: str
age: int
async def process_body(user: User):
return user
Where here the post can be directly sent like:
{
"name": "lilya", "age": 20
}
Fixed¶
- Typing for
settings_modulethat was not parsing properly. requestBodywas not displaying when it was required and enabled.- The parsing of the request body via decorator and BaseHandler if
infer_bodyis on.
0.15.2¶
Fixed¶
- Migration to Sayer missed the
rundirective argument required as False. - Missing
appswhen generating a project with structure.
0.15.1¶
Fixed¶
- This was supposed to go in the release 0.15.0 but a requirement was missing.
0.15.0¶
Added¶
- Support for OpenAPI documentation under the new
@openapi()decorator. This is optional and can be used to document your API endpoints with OpenAPI specifications without the need of any external library.
Changed¶
lilya runserveris nor revamped with modern UI and logs.lilya runservernow supportsworkersandproxy-headersparameters.
0.14.2¶
Changed¶
- Update internals of cli with the latest Sayer version.
0.14.1¶
Fixed¶
observablewas causing AnyIO problems.
0.14.0¶
Due to type advancements of the ecosystem, it was decided to drop support for Python 3.9 so we can unify syntaxes and tools.
Added¶
- Integration with Sayer for the Lilya CLI. This is a massive milestone for Lilya as it allows you to use the Lilya CLI with the Sayer CLI, which is a powerful tool for managing your Lilya applications or any other, really.
Changed¶
- Typing for
add_routeallowing controllers to be recognised. - Rename
show_urlsdirective toshow-urls. This is a breaking change as the directive name has changed but slightly more consistent with the rest of the directives. - Drop support for Python 3.9 due technology advancements.
0.13.7¶
Added¶
- Add
populate_contextparameter forGlobalContextMiddleware. - Add
populate_global_contextparameter forLilya. - Add
populate_sessionparameter forSessionMiddleware. LifespanGlobalContextMiddlewarewhich is initializinggfor lifespans.
Changed¶
GlobalContextMiddlewarewas initializinggfor lifespans Now this is moved toLifespanGlobalContextMiddleware.
Fixed¶
SessionContextwas not working for websockets.- Allow sniffing with
GlobalRequestContext.
0.13.6¶
Fixed¶
render_templatewas checking the wrong order in the TemplateController and ListController.
0.13.5¶
Added¶
- Support for TemplateController.
- Support for ListController.
0.13.4¶
Changed¶
- Replace in encoders the contextVar ENCODER_TYPES with a TransparentCage (monkay, works like a ContextVar mixed with a Sequence).
- Lazy evaluate the environment variable for the settings import. This relaxes the restraints on the import order.
You can e.g. import lilya settings before adjusting
LILYA_SETTINGS_MODULEas long as you don't access the settings object.
0.13.3¶
Added¶
- New LoggingConfig for the logging configuration. This now allows you to setup your own logging system and plug it with anything you want and then use the global logger from Lilya to log your messages by simply using:
from lilya.logging import logger
logger.info("My message in my logger.")
StandardLogging as the new default logging system of Lilya, removing the dependency of loguru and make this one
optional.
Fixed¶
- Missing
before_requestandafter_requestin the global Lilya settings.
0.13.2¶
Changed¶
- Deduplicate code between Router and Lilya. Move methods in a mixin.
- Move some methods and properties from BaseLilya to Lilya.
- Unprefix load_settings_value.
0.13.1¶
Changed¶
- Proper instance tracking.
0.13.0¶
Changed¶
- FileResponse tries to offload the file response to the server in case it supports the extensions.
- monkay as the lazy settings manager.
Removed¶
- Old LazyObject settings system allowing for more flexibility from monkay.
0.12.11¶
Added¶
- Observables documentation section. This is a new feature that allows to create observables that can be used to create a more reactive programming style.
Fixed¶
- Header fix for uvicorn wasn't working anymore after a dependency update. Allow bytes header keys.
0.12.10¶
Fixed¶
override_settingswas not having the override import behaviour expected.
0.12.9¶
Added¶
- Missing before and after request in the handler helpers.
0.12.8¶
Added¶
Lilya,Include,Host,PathandRouternow supportbefore_requestandafter_requestlife cycles. This can be particularly useful to those who want to perform actions before and after a request is performed. E.g.: Telemetry.- Added
versionto Lilya client.
Changed¶
- Declaring
DefinePermissionbecame optional as Lilya automatically wraps if not provided. -
Declaring
DefineMiddlewarebecame optional as Lilya automatically wraps if not provided.¶
Fixed¶
SessionMiddlewarewas creating duplicates because it was called on every lifecycle.
0.12.6¶
Fixed¶
- Bug with uvicorn. It assumes the headers in scope being a list instead of an iterator.
0.12.5¶
Added¶
- Header is now an iterator which is an alias to encoded_multi_items.
Instead of reparsing the headers for every middleware, keep the instance and mimic a fitting generator.-
sniffmethod on Request.
Changed¶
receive,sendare not properties anymore on Request but proper methods.receivehas a replay mode forsniff.
Fixed¶
- StaticFiles without scope headers failed.
- StaticFiles were susceptible for path traversal attacks.
- Calling Request.headers could empty the headers in scope when just a generator.
- Messages were not replayed in case
ContinueRoutingwas raised. This prevented sniffing like documented.
0.12.4¶
Added¶
- Compatibility mode for async response content.
- Support for jinja enable_async option.
0.12.3¶
Fixed¶
from_scopewas incorrectly applied in some middleware on scope and not on message for updated message headers. This breaks for example post responses.
0.12.2¶
Fixed¶
- Context G threads safety
0.12.1¶
Added¶
- New SessionContextMiddleware allowing to use the new
sessionobject in a request context.
Changed¶
- Updated the Context section by adding the session context examples and explanation how to use it.
0.12.0¶
Added¶
- Support for Python 3.13.
- Add
ReceiveSendSniffer. This sniffer allows to detect communication events and to replay receive messages. IncludeandBaseLilya(application) have now a ClassVarrouter_classto provide a custom router.- Subclasses of
BaseLilya(application) can set therouter_classto None to provide a completely custom router which initialization parameters aren't required to match the ones ofRouter. - Expose
fall_throughonStaticFile.
Changed¶
- The
PathHandlerinterface was changed to receive aReceiveSendSnifferinstead ofsend/receive. - The
handle_partialinterface was changed to receive aPathHandler. - Fall-through routing was implemented.
- Expose
redirect_slashesonInclude.
Fixed¶
Hostwith middleware or permissions.
0.11.11¶
Fixed¶
- Some middleware are not multithreading/async capable.
0.11.10¶
Added¶
- Add
passthrough_body_typesfor passing memoryviews and bytearrays directly to the application server.
Changed¶
- TestClient validates more ASGI conformance. It raises an
ASGISpecViolationerror for spec violations whencheck_asgi_conformanceis True (default). - Response's
make_headersnow setheadersdirectly. - Response's
headersis now a attribute. - Response's
raw_headersis now an alias forencoded_headers.
Fixed¶
- Ensure the response output is bytes when not
passthrough_body_typesis set. Defaults to passing through bytes. - Properly handle bytearrays.
- Properly parse header values. Properly handle cases in which header values are passed as an array in a dictionary.
- Properly set cookies.
0.11.9¶
Added¶
- Add
session_serializer,session_deserializerparameters toSessionMiddleware.
Changed¶
- Refactor
SessionMiddleware. - Refactor authentication.
- Allow multiple backends in
AuthenticationMiddleware. - Move backend logic from
BaseAuthMiddlewaretoAuthenticationMiddleware. Matches documentation. - Rename BaseUser to UserInterface and make it a protocol. Note: the old name is still available for compatibility reasons.
- Remove undocumented stub definitions from UserInterface. They were unsound.
Fixed¶
- Authentication documentation referenced non-existing structures.
- Available middleware section in middleware.md was not up to date.
- Fix serialization of primitives in the Response. Strip
"by default.
0.11.8¶
Fixed¶
- Fix too strict json_encoder_fn enforcment.
- Fix empty [] and {} becoming incorrectly an empty response in json context.
0.11.7¶
Added¶
- Add bytes encoder to encoders.
- Allow using DefineMiddleware and DefinePermission with import strings.
Changed¶
- Move simplify logic from
make_responseto Response but keep old interface. - Move esmerald Response
transformto lilya.
Fixed¶
- Fix unnecessary roundtrip in JSONResponse.
0.11.6¶
Added¶
- Add
redirectfunction as a wrapper to returnResponseRedirectresponses. Import happens insidelilya.responses import redirect.
Changed¶
- Make
gobject automatically managed by Lilya middleware. You no longet need to import theGlobalContextMiddlewareas it is a default Lilya middleware.
0.11.5¶
Added¶
RequestContextMiddlewareadded allowing request objects being used without a context of a request without explicitly declaring it inside handlers.
Changed¶
- Allow multiple directories in
StaticFiles. This enables providing overwrites/defaults.
0.11.4¶
Added¶
GlobalContextMiddlewarethe new middleware that allows you to havegobject across the request lifecycle and set global variables to be accessed through that same lifecycle.- The g definition and declaration.
Changed¶
- Remove hard dependency of
dymmond-settings.
0.11.3¶
Changed¶
- Lilya middleware for Authentication refactored to allow backends to be passed as parameter.
Fixed¶
- Ensure encoders used for
apply_structurehave at leastencodeandis_type_structure. The remaining methods are ensured byEncodeProtocolcheck.
0.11.2¶
Changed¶
- Encoders saved on responses are ensured to be instances and not classes.
Fixed¶
- Crash when passing string to is_type_structure (e.g. string annotations).
- Fix Encoder type in responses.
0.11.1¶
Added¶
__encode__flag to all native encoders.
Fixed¶
StructureEncodertype was pointing to the wrong structures.
0.11.0¶
Changed¶
- Enhanced encoders:
ENCODER_TYPESis now a context-variable.- New encoders for datetime and date.
- Former
json_encoderis now exported via public API asjson_encode. The old name is still available in_internal. - New method
apply_structure, which allows input parsing. make_responsedoes not support encoders as class anymore only as instance.
Fixed¶
typing_extensionserrors on python >= 3.10.- Address deprecation warnings in tests.
- Fix encoders applied after simplifying response.
0.10.2¶
Changed¶
- Lilya is now BSD-3 licence compliant to protect the developers and mantainers.
Fixed¶
runserverwas not being application agnostic.
0.10.1¶
Added¶
- New
ClientIPMiddlewareadded allowing retrieving IP information directly.
Changed¶
- The Lilya directives now use Taskfile when generating a project.
0.10.0¶
Changed¶
- Rename EnvironmentException to EnvException (but keep old name as alias).
- Drop support for python<3.9.
ENCODER_TYPESare now ordered and new encoders are prepend.
0.9.1¶
Added¶
- CORSMiddleware now supports the
allow_private_networksboolean parameter. This prepares for what is coming for Chromium based browsers.
Changed¶
- Internal testing for Edgy with the new drivers.
0.9.0¶
Added¶
- The new possibility of declaring routes using lilya as decorator.
Example¶
from lilya.apps import Lilya
from lilya.requests import Request
from lilya.responses import Ok
app = Lilya()
@app.get("/")
async def welcome():
return Ok({"message": "Welcome to Lilya"})
@app.get("/{user}")
async def user(user: str):
return Ok({"message": f"Welcome to Lilya, {user}"})
@app.get("/in-request/{user}")
async def user_in_request(request: Request):
user = request.path_params["user"]
return Ok({"message": f"Welcome to Lilya, {user}"})
0.8.3¶
Changed¶
- Internal app generator simple now returns async examples by default.
- Update encoding to be
utf-8by default.
0.8.2¶
This was supposed to in the version 0.8.1
Fixed¶
- LRU caching affecting connections from request.
0.8.1¶
Changed¶
- Removed unused middleware.
- Updated AppSettingsMiddleware for lazy loading
- Updated
globalise_settings.
Fixed¶
- Performance issues caused by
AppSettingsModule.
0.8.0¶
Added¶
XFrameOptionsMiddlewareto handle with options headers.SecurityMiddlewareadding various security headers to the request/response lifecycle.override_settingsas new decorator that allows to override the Lilya settings in any given test.
Fixed¶
- Missing status
HTTP_301_MOVED_PERMANENTLYfrom the list of available status.
0.7.5¶
Added¶
- Allow path parameters to also be defined with
<>as alternative to{}.
Example¶
from lilya.routing import Path
Path("/<age:int>", ...)
0.7.4¶
Added¶
- Translations to portuguese.
Fixed¶
- Missing
settingsin therunserverdirective.
0.7.3¶
Fixed¶
- Documentation generation for
typing.Unpack.
0.7.2¶
Changed¶
- Optimised the
encodersand how it evaluates theENCODER_TYPES. - Internal fixes in the
TestClientand internals.
0.7.1¶
Fixed¶
- Import cast clashing with local variables.
0.7.0¶
Added¶
- New EnvironLoader support.
Fixed¶
- Internal
AsyncExitStackmiddleware raising exception.
0.6.1¶
Changed¶
- Internal support for
hatchand removed the need for aMakefile - Documentation references
- Internals for Directives. #54 by @devkral.
0.6.0¶
Fixed¶
add_argumentsfrom BaseDirective to not raiseNotImplementedErrorexception.
0.5.0¶
Added¶
settings_modulealso supports import as string
Example¶
from lilya.apps import Lilya
from lilya.requests import Request
from lilya.routing import Path
async def home(): ...
app = Lilya(
routes=[Path("/", handler=home)],
settings_module="myapp.configs.settings.AppSettings",
)
0.4.0¶
Added¶
encodersdirectly embed in any response. Theencodersis a list oflilya.encoder.Encodertype of objects that can be passed directly into the response. SInce the responses can be independent ASGI applications, the encoders can be passed directly there.
0.3.5¶
Changed¶
- Documentation improvements.
Fixed¶
- Typo in the create project directive urls file descripton.
0.3.4¶
Added¶
- Extra validations to handle the events.
0.3.3¶
Added¶
settings_modulewhen passed in the instance of Lilya will take precedence over the global settings, removing the need of using constantly theLILYA_SETTINGS_MODULE.ApplicationSettingsMiddlewareas internal that handles with thesettings_moduleprovided and maps the context of the settings.
Example of the way the settings are evaluated¶
from dataclasses import dataclass
from lilya.apps import Lilya
from lilya.conf import settings
from lilya.conf.global_settings import Settings
from lilya.responses import Ok
from lilya.routing import Include, Path
async def home():
title = getattr(settings, "title", "Lilya")
return Ok({"title": title, "debug": settings.debug})
@dataclass
class NewSettings(Settings):
title: str = "Settings being parsed by the middleware and make it app global"
debug: bool = False
@dataclass
class NestedAppSettings(Settings):
title: str = "Nested app title"
debug: bool = True
app = Lilya(
settings_module=NewSettings,
routes=[
Path("/home", handler=home),
Include(
"/child",
app=Lilya(
settings_module=NestedAppSettings,
routes=[
Path("/home", handler=home),
],
),
),
],
)
In the context of the controller home, based on the path being called, it should return the
corresponding value of the title according to the settings of the app that is included.
Changed¶
createappdirectiveviews.pyfile generated renamed tocontrollers.py.
0.3.2¶
Fixed¶
- Missing requirements needed for the
pip install lilya[cli]
0.3.1¶
Added¶
- New
await request.data()andawait request.text(). mediatoRequestobject returning a dict containing the content type media definitions in a dictionary like format.
0.3.0¶
Added¶
- Allow
EncoderandTransformerto be registered without forcing to be instances.
Changed¶
- Add
__slots__toRequest.
0.2.3¶
Added¶
- Alias
Middlewareto be imported fromlilya.middleware.
Fixed¶
messagein responses was not passing the proper headers.
0.2.2¶
Added¶
- New lazy loading settings system making it more unique and dynamic.
0.2.1¶
Changed¶
- Update internal
dymmond-settingsminimum requirement.
0.2.0¶
Added¶
- Support for
leninSecretdatastructure.
Changed¶
- The way the signature is evaluated in the Path and WebSocketPath
- Internal code refactoring for signature and
include.
BREAKING CHANGE
SETTINGS_MODULEwas renamed toLILYA_SETTINGS_MODULE.
Fixed¶
namespacevalidation for Include.- Internal form parser was duplicating the values.
0.1.2¶
Fixed¶
Transformerto allow to be hashable from the dataclasses.
0.1.1¶
Fixed¶
- Context scope for app not being properly called from the request.
0.1.0¶
Initial release of Lilya.
- A lightweight ASGI toolkit.
- Support for HTTP/WebSocket.
- Tasks (in ASGI known as background tasks).
- Lifespan events (on_startup/on_shutdown and lifespan).
- Native permission system.
- Middlewares (Compressor, CSRF, Session, CORS...).
- A native and optional client.
- Directive management control system for any custom scripts to run inside the application.
- Dynamic routing system with the help of the native Include and minimum boilerplate.
- Native settings system. No more bloated instances.