Conversation
style: apply ruff linting fixes and modernize type hints
- Created unit tests for the requests module, covering query parsing, body parsing, header parsing, and request initialization. - Implemented unit tests for the router class, including route registration, HTTP methods, and programmatic route addition. - Added unit tests for the server class, testing initialization, start method, and integration with WSGI applications. - Developed unit tests for the templator class, focusing on initialization, template rendering, error handling, and integration with Jinja2.
…e annotations and compliance with standards. fix(code): adjusted the code to align with the new configurations and requirements for type annotations.
…documentation feat(dev): implement development server with hot reload functionality feat(toml): add script entry point and update dependency groups in pyproject.toml
- Create project structure guide with minimal and recommended layouts - Add quickstart guide for building "Hello, World!" application - Document request handling: attributes, methods, and data parsing - Provide routing documentation: decorators, path parameters, and router usage - Update index and installation instructions for better clarity - Configure mkdocs for improved presentation and navigation
- Clean up imports and remove unused ones across test files - Standardize type hints for WSGI environment and request handling - Add explicit type annotations to router and request classes - Improve CLI commands for better readability and consistency - Add pre-commit configuration with Ruff and Mypy - Remove trailing whitespace and ensure newline at EOF - Update templator and view classes with proper type handling - Refactor DevServer class for better structure and clarity - General code cleanup to enhance maintainability
There was a problem hiding this comment.
Pull Request Overview
This pull request modernizes the Wiverno framework by adding comprehensive type hints, improving code quality, and introducing extensive testing and documentation infrastructure. Key changes include migrating to modern Python 3.12+ syntax with PEP 604 union types, adding a CLI interface with hot-reload development server, comprehensive test suite, and MkDocs-based documentation.
Key Changes:
- Modernized type hints using
|union syntax andcollections.abc.Callable - Added CLI with development/production server commands and documentation serving
- Introduced comprehensive test suite with unit, integration, and benchmark tests
- Removed
setup.pyin favor ofpyproject.tomlconfiguration - Enhanced
Templatorwithautoescape=Trueand improved path handling
Reviewed Changes
Copilot reviewed 56 out of 58 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wiverno/main.py | Added type hints, modernized imports, changed from typing.Callable to collections.abc.Callable |
| wiverno/core/requests.py | Added type hints for all methods, modernized syntax, improved parsing logic |
| wiverno/core/router.py | Added type hints, new get_routes() method, modernized decorators |
| wiverno/core/server.py | Added type hints, reorganized imports |
| wiverno/templating/templator.py | Added autoescape=True, Path support, improved path handling |
| wiverno/views/base_views.py | Added type hints and import for Request |
| wiverno/cli.py | New CLI interface with Typer for server and docs commands |
| wiverno/dev/dev_server.py | New development server with hot-reload functionality |
| wiverno/init.py | Version detection using importlib.metadata |
| tests/ | Comprehensive test suite with fixtures and examples |
| docs/ | Complete MkDocs documentation structure |
| pyproject.toml | Extensive configuration with tools, dependencies, scripts |
| requirements.txt | Binary/encoding issue with content |
| setup.py | Removed in favor of pyproject.toml |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wiverno/main.py
Outdated
| """ | ||
| for route_info in router._routes: | ||
| full_path = prefix + route_info['path'] | ||
| for route_info in router.get_routes(): |
There was a problem hiding this comment.
The code now calls router.get_routes() instead of accessing router._routes directly. While this is a better API design using the public method, ensure this change doesn't break existing code that might have been accessing _routes directly. The get_routes() method was added in router.py, which is good encapsulation.
| if hasattr(msg, "iter_parts"): | ||
| for part in msg.iter_parts(): | ||
| name: str | None = part.get_param("name", header="content-disposition") | ||
| if name: | ||
| data[name] = part.get_content() |
There was a problem hiding this comment.
The addition of hasattr(msg, 'iter_parts') check before calling iter_parts() is defensive programming, but it silently fails if iter_parts doesn't exist. This means multipart form data parsing will return an empty dict without any indication of what went wrong. Consider logging a warning or handling this case more explicitly.
| "[green]$ uv pip install -e .[dev][/green]" | ||
| ) | ||
| raise typer.Exit(1) from e | ||
| except KeyboardInterrupt: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
- Implement comprehensive DevServer tests: - DebounceHandler functionality - Server initialization and configuration - Process management (start/stop methods) - Hot reload and file change detection - Add Wiverno application tests: - Error handling (404, 405, 500 responses) - Route decorators and functionality - Router inclusion and route matching - WSGI integration and request-response cycle - Edge cases and debug mode behavior
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 57 out of 59 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wiverno/main.py
Outdated
| if prefix: | ||
| prefix = prefix.rstrip("/") | ||
| if not prefix.startswith("/"): | ||
| prefix = "/" + prefix | ||
|
|
||
| full_path = '/' + full_path.strip('/') | ||
| if full_path != '/': | ||
| full_path = full_path.rstrip('/') | ||
| for path, route_data in router._routes.items(): |
There was a problem hiding this comment.
The code iterates over router._routes.items() but Router class uses a list _routes: list[dict[str, Any]], not a dict. This will cause an AttributeError at runtime. The iteration should be over the list elements directly or Router needs to expose routes differently.
| self.env.loader = FileSystemLoader(os.path.join(self.base_dir, folder)) | ||
|
|
||
| def render(self, template_name: str, content: Optional[dict] = None, **kwargs): | ||
| self.env = Environment(autoescape=True) |
There was a problem hiding this comment.
While enabling autoescape by default is a security improvement, this is a breaking change that could affect existing templates that expect raw HTML output. Consider documenting this change prominently or providing a configuration option to disable it for backward compatibility.
|
|
||
|
|
||
| def route(self, path: str, methods: Optional[List[str]] = None): | ||
| self._routes: list[dict[str, Any]] = [] |
There was a problem hiding this comment.
The Router class stores routes as a list of dictionaries with string keys, but wiverno/main.py line 265 attempts to call .items() on router._routes as if it were a dict. This data structure inconsistency will cause runtime errors. Either Router should use a dict internally, or the usage in main.py needs to be corrected.
* 0.1.0 Version (#3) * feat(core): implement GET and POST request handling, add WSGI server - Added request parsing for both GET and POST methods - Implemented a minimal WSGI-compatible server - Updated .gitignore to exclude virtual environments and compiled files * Fix: Improve request handling and enhance template rendering * refactor(router): switch from dict to list of (path, handler) tuples in routes * fix(docs): update argument type in Wiverno constructor documentation * refactor(main): enhance Wiverno initialization and error handling * refactor(main): streamline request handling and enhance error logging * refactor: reorganize project structure and move request handling to core module * refactor(requests): simplify query string parsing and enhance POST data handling refactor(server): improve server shutdown handling with user feedback * feat(errors): implement custom 404 and 500 error pages with improved visualization. Add the ability to connect custom pages for 404 and 500 errors. Fixed an incorrect path in the Templator * feat(errors): remove old error templates and add new ones in the static directory * feat(errors): implement MethodNotAllowed405 handler and improve error page rendering * docs: improve README and add packaging (#2) * feat: check before merge * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor(templator): update base directory handling and improve template loading * fix: correct 404 response message and type annotation for system_templator --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(dependencies): adding dependency configuration file The `pyproject.toml` file has been added. The `requirements.txt` file has been updated. The files `.python-version` and `uv.lock` have been added to `.gitignore`. * Feat/alternative routing methods (#4) * feat(router): implement routing functionality with method decorators feat(errors): enhance 500 error page with traceback display * feat(docs): add docstrings for classes and methods across the codebase * feat(version): update version to 0.1.1 and improve logging in server * feat(router): set default HTTP methods for route handlers * feat(version): update version to 0.1.1 in setup.py fix(router): remove default methods in router class fix(main): remove default methods in Wiverno class * fix(router): clarify comment on default HTTP methods for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * chore/project-setup(#5) * build(deps): configure uv dependency management and project metadata style: apply ruff linting fixes and modernize type hints * feat(tests): add unit tests for Wiverno framework components - Created unit tests for the requests module, covering query parsing, body parsing, header parsing, and request initialization. - Implemented unit tests for the router class, including route registration, HTTP methods, and programmatic route addition. - Added unit tests for the server class, testing initialization, start method, and integration with WSGI applications. - Developed unit tests for the templator class, focusing on initialization, template rendering, error handling, and integration with Jinja2. * feat(config): updated configurations for Ruff and MyPy to enhance type annotations and compliance with standards. fix(code): adjusted the code to align with the new configurations and requirements for type annotations. * feat(cli): add CLI interface with commands for server management and documentation feat(dev): implement development server with hot reload functionality feat(toml): add script entry point and update dependency groups in pyproject.toml * docs(framework): add comprehensive documentation for Wiverno - Create project structure guide with minimal and recommended layouts - Add quickstart guide for building "Hello, World!" application - Document request handling: attributes, methods, and data parsing - Provide routing documentation: decorators, path parameters, and router usage - Update index and installation instructions for better clarity - Configure mkdocs for improved presentation and navigation * refactor(codebase): improve readability and type hinting - Clean up imports and remove unused ones across test files - Standardize type hints for WSGI environment and request handling - Add explicit type annotations to router and request classes - Improve CLI commands for better readability and consistency - Add pre-commit configuration with Ruff and Mypy - Remove trailing whitespace and ensure newline at EOF - Update templator and view classes with proper type handling - Refactor DevServer class for better structure and clarity - General code cleanup to enhance maintainability * test(core): add unit tests for DevServer and Wiverno application - Implement comprehensive DevServer tests: - DebounceHandler functionality - Server initialization and configuration - Process management (start/stop methods) - Hot reload and file change detection - Add Wiverno application tests: - Error handling (404, 405, 500 responses) - Route decorators and functionality - Router inclusion and route matching - WSGI integration and request-response cycle - Edge cases and debug mode behavior * chore(coverage): exclude cli.py and dev_server.py from coverage reports * refactor(router): improve route inclusion logic and handle prefix normalization * refactor(router): enhance route normalization and data structure for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Feat/Refactor routing system(#6) * Refactor routing system and enhance request handling - Introduced a new routing structure with Router and RouterRegistry classes to manage routes more effectively. - Removed the old Router class and replaced it with a mixin-based approach for better modularity. - Implemented PathPattern for dynamic route matching with support for FastAPI-style parameters. - Enhanced the Request class to normalize paths correctly, ensuring consistent behavior across the application. - Updated the Wiverno application to utilize the new routing system, allowing for cleaner route management and error handling. - Simplified the DevServer class by removing unnecessary comments and improving code clarity. - Refined the Templator class to streamline template loading from specified directories. - Cleaned up the BaseView class documentation for clarity and removed example code to focus on the class's purpose. * feat(linting): update pre-commit configuration and exclude test files from linting refactor(tests): clean up test files by removing unnecessary blank lines refactor(routing): improve router registry access and enhance route registration methods fix(requests): add path_params attribute to Request class for dynamic route parameters --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix/query param overwrite (#7) * feat(requirements): fixing a broken character * feat(requests): replace ParseQuery with QueryDict for multi query string handling --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix(docs): Update import statement for Wiverno * Feat: Extract page logic into separate classes and update imports (#8) * Update docs after code refactoring (#9) * Feat: Update documentation and examples for dynamic routing and path parameters * Feat(docs): Update documentation and examples to reflect changes in application entry point and routing system * Fix: Update project version to 1.0.0 in pyproject.toml * fix(tests): delete test file * feat(deploy): pypi deploy(#10) * hotfix(deploy): fixed publisher file name * fix(README): added pypi project name * fix(pyproject): fix project version * fix: move CLI dependencies to main requirements - Move typer, rich, and watchdog from optional dev dependencies to main dependencies - Fix ModuleNotFoundError when running wiverno CLI after installation - Update documentation to use run.py as default module name - Remove unnecessary --app-module flags from documentation examples - Generate requirements.txt and requirements-dev.txt files * docs: update README with documentation, requirements, contributing guidelines, and authors * feat: Update version
* 0.1.0 Version (#3) * feat(core): implement GET and POST request handling, add WSGI server - Added request parsing for both GET and POST methods - Implemented a minimal WSGI-compatible server - Updated .gitignore to exclude virtual environments and compiled files * Fix: Improve request handling and enhance template rendering * refactor(router): switch from dict to list of (path, handler) tuples in routes * fix(docs): update argument type in Wiverno constructor documentation * refactor(main): enhance Wiverno initialization and error handling * refactor(main): streamline request handling and enhance error logging * refactor: reorganize project structure and move request handling to core module * refactor(requests): simplify query string parsing and enhance POST data handling refactor(server): improve server shutdown handling with user feedback * feat(errors): implement custom 404 and 500 error pages with improved visualization. Add the ability to connect custom pages for 404 and 500 errors. Fixed an incorrect path in the Templator * feat(errors): remove old error templates and add new ones in the static directory * feat(errors): implement MethodNotAllowed405 handler and improve error page rendering * docs: improve README and add packaging (#2) * feat: check before merge * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor(templator): update base directory handling and improve template loading * fix: correct 404 response message and type annotation for system_templator --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(dependencies): adding dependency configuration file The `pyproject.toml` file has been added. The `requirements.txt` file has been updated. The files `.python-version` and `uv.lock` have been added to `.gitignore`. * Feat/alternative routing methods (#4) * feat(router): implement routing functionality with method decorators feat(errors): enhance 500 error page with traceback display * feat(docs): add docstrings for classes and methods across the codebase * feat(version): update version to 0.1.1 and improve logging in server * feat(router): set default HTTP methods for route handlers * feat(version): update version to 0.1.1 in setup.py fix(router): remove default methods in router class fix(main): remove default methods in Wiverno class * fix(router): clarify comment on default HTTP methods for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * chore/project-setup(#5) * build(deps): configure uv dependency management and project metadata style: apply ruff linting fixes and modernize type hints * feat(tests): add unit tests for Wiverno framework components - Created unit tests for the requests module, covering query parsing, body parsing, header parsing, and request initialization. - Implemented unit tests for the router class, including route registration, HTTP methods, and programmatic route addition. - Added unit tests for the server class, testing initialization, start method, and integration with WSGI applications. - Developed unit tests for the templator class, focusing on initialization, template rendering, error handling, and integration with Jinja2. * feat(config): updated configurations for Ruff and MyPy to enhance type annotations and compliance with standards. fix(code): adjusted the code to align with the new configurations and requirements for type annotations. * feat(cli): add CLI interface with commands for server management and documentation feat(dev): implement development server with hot reload functionality feat(toml): add script entry point and update dependency groups in pyproject.toml * docs(framework): add comprehensive documentation for Wiverno - Create project structure guide with minimal and recommended layouts - Add quickstart guide for building "Hello, World!" application - Document request handling: attributes, methods, and data parsing - Provide routing documentation: decorators, path parameters, and router usage - Update index and installation instructions for better clarity - Configure mkdocs for improved presentation and navigation * refactor(codebase): improve readability and type hinting - Clean up imports and remove unused ones across test files - Standardize type hints for WSGI environment and request handling - Add explicit type annotations to router and request classes - Improve CLI commands for better readability and consistency - Add pre-commit configuration with Ruff and Mypy - Remove trailing whitespace and ensure newline at EOF - Update templator and view classes with proper type handling - Refactor DevServer class for better structure and clarity - General code cleanup to enhance maintainability * test(core): add unit tests for DevServer and Wiverno application - Implement comprehensive DevServer tests: - DebounceHandler functionality - Server initialization and configuration - Process management (start/stop methods) - Hot reload and file change detection - Add Wiverno application tests: - Error handling (404, 405, 500 responses) - Route decorators and functionality - Router inclusion and route matching - WSGI integration and request-response cycle - Edge cases and debug mode behavior * chore(coverage): exclude cli.py and dev_server.py from coverage reports * refactor(router): improve route inclusion logic and handle prefix normalization * refactor(router): enhance route normalization and data structure for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Feat/Refactor routing system(#6) * Refactor routing system and enhance request handling - Introduced a new routing structure with Router and RouterRegistry classes to manage routes more effectively. - Removed the old Router class and replaced it with a mixin-based approach for better modularity. - Implemented PathPattern for dynamic route matching with support for FastAPI-style parameters. - Enhanced the Request class to normalize paths correctly, ensuring consistent behavior across the application. - Updated the Wiverno application to utilize the new routing system, allowing for cleaner route management and error handling. - Simplified the DevServer class by removing unnecessary comments and improving code clarity. - Refined the Templator class to streamline template loading from specified directories. - Cleaned up the BaseView class documentation for clarity and removed example code to focus on the class's purpose. * feat(linting): update pre-commit configuration and exclude test files from linting refactor(tests): clean up test files by removing unnecessary blank lines refactor(routing): improve router registry access and enhance route registration methods fix(requests): add path_params attribute to Request class for dynamic route parameters --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix/query param overwrite (#7) * feat(requirements): fixing a broken character * feat(requests): replace ParseQuery with QueryDict for multi query string handling --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix(docs): Update import statement for Wiverno * Feat: Extract page logic into separate classes and update imports (#8) * Update docs after code refactoring (#9) * Feat: Update documentation and examples for dynamic routing and path parameters * Feat(docs): Update documentation and examples to reflect changes in application entry point and routing system * Fix: Update project version to 1.0.0 in pyproject.toml * fix(tests): delete test file * feat(deploy): pypi deploy(#10) * hotfix(deploy): fixed publisher file name * fix(README): added pypi project name * fix(pyproject): fix project version * fix: move CLI dependencies to main requirements - Move typer, rich, and watchdog from optional dev dependencies to main dependencies - Fix ModuleNotFoundError when running wiverno CLI after installation - Update documentation to use run.py as default module name - Remove unnecessary --app-module flags from documentation examples - Generate requirements.txt and requirements-dev.txt files * docs: update README with documentation, requirements, contributing guidelines, and authors * feat: Update version * HTTP status validation (#12) * feat(http): add HTTP status code validation and normalization Implement comprehensive HTTP status validation system with automatic normalization to WSGI-compliant format following best practices. Structure: - Add wiverno/core/exceptions.py with InvalidHTTPStatusError - Add wiverno/core/http/validator.py with HTTPStatusValidator - Create HTTPStatusValidator.normalize_status() for status code handling Features: - Accept int or str status codes (e.g., 200, "404", "200 OK") - Automatic conversion to WSGI format ("404 Not Found") - Auto-correction of malformed strings ("404 Wrong" → "404 Not Found") - Validation with InvalidHTTPStatusError for invalid inputs - Support for all standard HTTP status codes (1xx-5xx) Implementation: - Update main.py to normalize all status codes through validator - Modify default error pages (404/405/500) to return integers - Apply normalization to both handler responses and error pages - Add comprehensive docstrings with usage examples Testing: - Add 35 unit tests in tests/unit/test_http_validator.py * Test all HTTP status code ranges (1xx-5xx) * Test int/str input handling and edge cases * Test error handling and exception behavior - Add 10 integration tests in tests/integration/test_http_status.py * Test status validation in full application context * Verify handler int/str status compatibility * Ensure default error pages work correctly - Update 9 existing tests to expect integer status codes - Coverage: 96.45% (up from 94.22%) Breaking Changes: - Default error handlers (404/405/500) now return int status codes - BaseView error responses return int that require normalization - Custom error handlers should return int or properly formatted strings Fixes: - Handle empty string status codes correctly - Preserve original invalid values in exception for debugging - Ensure consistent status format across all response paths - Fix Russian error messages to English * Refactor response handling to omit status codes in view functions - Updated view functions across documentation to return responses without explicit status codes for successful requests (200 OK). - Added a new guide on HTTP Status Codes to explain usage and best practices. - Adjusted examples in the routing, requests, and quickstart guides to reflect the new response format. - Ensured consistency in documentation regarding response handling and status code usage. * fix: update branch names in CI workflow to match current branches * Enhance built-in servers (#13) * docs(server): enhance server documentation and add graceful shutdown - Add comprehensive "Running Your Application" guide covering DevServer and RunServer - Create dedicated API reference pages for both servers with detailed examples - Enhance RunServer with graceful shutdown (SIGINT/SIGTERM), stop() method, and configurable request_queue_size - Refactor DevServer API: _start() private, serve() public static method - Update all unit tests to match new server API (94.53% coverage, 280 tests passing) - Fix CLI command references in documentation (wiverno run dev/prod) BREAKING CHANGE: DevServer.start() is now private. Use DevServer.serve() instead. * fix: update documentation and tests for HTTP status code 413 * fix: remove obsolete HTTP status codes from tests * feat: update project version to 1.0.3 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…#15) * Release 1.0.3 * 0.1.0 Version (#3) * feat(core): implement GET and POST request handling, add WSGI server - Added request parsing for both GET and POST methods - Implemented a minimal WSGI-compatible server - Updated .gitignore to exclude virtual environments and compiled files * Fix: Improve request handling and enhance template rendering * refactor(router): switch from dict to list of (path, handler) tuples in routes * fix(docs): update argument type in Wiverno constructor documentation * refactor(main): enhance Wiverno initialization and error handling * refactor(main): streamline request handling and enhance error logging * refactor: reorganize project structure and move request handling to core module * refactor(requests): simplify query string parsing and enhance POST data handling refactor(server): improve server shutdown handling with user feedback * feat(errors): implement custom 404 and 500 error pages with improved visualization. Add the ability to connect custom pages for 404 and 500 errors. Fixed an incorrect path in the Templator * feat(errors): remove old error templates and add new ones in the static directory * feat(errors): implement MethodNotAllowed405 handler and improve error page rendering * docs: improve README and add packaging (#2) * feat: check before merge * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update wiverno/templating/templator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor(templator): update base directory handling and improve template loading * fix: correct 404 response message and type annotation for system_templator --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(dependencies): adding dependency configuration file The `pyproject.toml` file has been added. The `requirements.txt` file has been updated. The files `.python-version` and `uv.lock` have been added to `.gitignore`. * Feat/alternative routing methods (#4) * feat(router): implement routing functionality with method decorators feat(errors): enhance 500 error page with traceback display * feat(docs): add docstrings for classes and methods across the codebase * feat(version): update version to 0.1.1 and improve logging in server * feat(router): set default HTTP methods for route handlers * feat(version): update version to 0.1.1 in setup.py fix(router): remove default methods in router class fix(main): remove default methods in Wiverno class * fix(router): clarify comment on default HTTP methods for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * chore/project-setup(#5) * build(deps): configure uv dependency management and project metadata style: apply ruff linting fixes and modernize type hints * feat(tests): add unit tests for Wiverno framework components - Created unit tests for the requests module, covering query parsing, body parsing, header parsing, and request initialization. - Implemented unit tests for the router class, including route registration, HTTP methods, and programmatic route addition. - Added unit tests for the server class, testing initialization, start method, and integration with WSGI applications. - Developed unit tests for the templator class, focusing on initialization, template rendering, error handling, and integration with Jinja2. * feat(config): updated configurations for Ruff and MyPy to enhance type annotations and compliance with standards. fix(code): adjusted the code to align with the new configurations and requirements for type annotations. * feat(cli): add CLI interface with commands for server management and documentation feat(dev): implement development server with hot reload functionality feat(toml): add script entry point and update dependency groups in pyproject.toml * docs(framework): add comprehensive documentation for Wiverno - Create project structure guide with minimal and recommended layouts - Add quickstart guide for building "Hello, World!" application - Document request handling: attributes, methods, and data parsing - Provide routing documentation: decorators, path parameters, and router usage - Update index and installation instructions for better clarity - Configure mkdocs for improved presentation and navigation * refactor(codebase): improve readability and type hinting - Clean up imports and remove unused ones across test files - Standardize type hints for WSGI environment and request handling - Add explicit type annotations to router and request classes - Improve CLI commands for better readability and consistency - Add pre-commit configuration with Ruff and Mypy - Remove trailing whitespace and ensure newline at EOF - Update templator and view classes with proper type handling - Refactor DevServer class for better structure and clarity - General code cleanup to enhance maintainability * test(core): add unit tests for DevServer and Wiverno application - Implement comprehensive DevServer tests: - DebounceHandler functionality - Server initialization and configuration - Process management (start/stop methods) - Hot reload and file change detection - Add Wiverno application tests: - Error handling (404, 405, 500 responses) - Route decorators and functionality - Router inclusion and route matching - WSGI integration and request-response cycle - Edge cases and debug mode behavior * chore(coverage): exclude cli.py and dev_server.py from coverage reports * refactor(router): improve route inclusion logic and handle prefix normalization * refactor(router): enhance route normalization and data structure for routes --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Feat/Refactor routing system(#6) * Refactor routing system and enhance request handling - Introduced a new routing structure with Router and RouterRegistry classes to manage routes more effectively. - Removed the old Router class and replaced it with a mixin-based approach for better modularity. - Implemented PathPattern for dynamic route matching with support for FastAPI-style parameters. - Enhanced the Request class to normalize paths correctly, ensuring consistent behavior across the application. - Updated the Wiverno application to utilize the new routing system, allowing for cleaner route management and error handling. - Simplified the DevServer class by removing unnecessary comments and improving code clarity. - Refined the Templator class to streamline template loading from specified directories. - Cleaned up the BaseView class documentation for clarity and removed example code to focus on the class's purpose. * feat(linting): update pre-commit configuration and exclude test files from linting refactor(tests): clean up test files by removing unnecessary blank lines refactor(routing): improve router registry access and enhance route registration methods fix(requests): add path_params attribute to Request class for dynamic route parameters --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix/query param overwrite (#7) * feat(requirements): fixing a broken character * feat(requests): replace ParseQuery with QueryDict for multi query string handling --------- Co-authored-by: Sayrrexe <sayrrexe@gmail.com> * Fix(docs): Update import statement for Wiverno * Feat: Extract page logic into separate classes and update imports (#8) * Update docs after code refactoring (#9) * Feat: Update documentation and examples for dynamic routing and path parameters * Feat(docs): Update documentation and examples to reflect changes in application entry point and routing system * Fix: Update project version to 1.0.0 in pyproject.toml * fix(tests): delete test file * feat(deploy): pypi deploy(#10) * hotfix(deploy): fixed publisher file name * fix(README): added pypi project name * fix(pyproject): fix project version * fix: move CLI dependencies to main requirements - Move typer, rich, and watchdog from optional dev dependencies to main dependencies - Fix ModuleNotFoundError when running wiverno CLI after installation - Update documentation to use run.py as default module name - Remove unnecessary --app-module flags from documentation examples - Generate requirements.txt and requirements-dev.txt files * docs: update README with documentation, requirements, contributing guidelines, and authors * feat: Update version * HTTP status validation (#12) * feat(http): add HTTP status code validation and normalization Implement comprehensive HTTP status validation system with automatic normalization to WSGI-compliant format following best practices. Structure: - Add wiverno/core/exceptions.py with InvalidHTTPStatusError - Add wiverno/core/http/validator.py with HTTPStatusValidator - Create HTTPStatusValidator.normalize_status() for status code handling Features: - Accept int or str status codes (e.g., 200, "404", "200 OK") - Automatic conversion to WSGI format ("404 Not Found") - Auto-correction of malformed strings ("404 Wrong" → "404 Not Found") - Validation with InvalidHTTPStatusError for invalid inputs - Support for all standard HTTP status codes (1xx-5xx) Implementation: - Update main.py to normalize all status codes through validator - Modify default error pages (404/405/500) to return integers - Apply normalization to both handler responses and error pages - Add comprehensive docstrings with usage examples Testing: - Add 35 unit tests in tests/unit/test_http_validator.py * Test all HTTP status code ranges (1xx-5xx) * Test int/str input handling and edge cases * Test error handling and exception behavior - Add 10 integration tests in tests/integration/test_http_status.py * Test status validation in full application context * Verify handler int/str status compatibility * Ensure default error pages work correctly - Update 9 existing tests to expect integer status codes - Coverage: 96.45% (up from 94.22%) Breaking Changes: - Default error handlers (404/405/500) now return int status codes - BaseView error responses return int that require normalization - Custom error handlers should return int or properly formatted strings Fixes: - Handle empty string status codes correctly - Preserve original invalid values in exception for debugging - Ensure consistent status format across all response paths - Fix Russian error messages to English * Refactor response handling to omit status codes in view functions - Updated view functions across documentation to return responses without explicit status codes for successful requests (200 OK). - Added a new guide on HTTP Status Codes to explain usage and best practices. - Adjusted examples in the routing, requests, and quickstart guides to reflect the new response format. - Ensured consistency in documentation regarding response handling and status code usage. * fix: update branch names in CI workflow to match current branches * Enhance built-in servers (#13) * docs(server): enhance server documentation and add graceful shutdown - Add comprehensive "Running Your Application" guide covering DevServer and RunServer - Create dedicated API reference pages for both servers with detailed examples - Enhance RunServer with graceful shutdown (SIGINT/SIGTERM), stop() method, and configurable request_queue_size - Refactor DevServer API: _start() private, serve() public static method - Update all unit tests to match new server API (94.53% coverage, 280 tests passing) - Fix CLI command references in documentation (wiverno run dev/prod) BREAKING CHANGE: DevServer.start() is now private. Use DevServer.serve() instead. * fix: update documentation and tests for HTTP status code 413 * fix: remove obsolete HTTP status codes from tests * feat: update project version to 1.0.3 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * ➖Added dependencies `annotated-doc` * 🎾 **Formated Code** ➖ Add import `annotated-doc` ➖ Clean `Callable code` * ➖ Rename `UserDict` on `dict` * ➖ Bump version --------- Co-authored-by: Wise <145248257+Sayrrexe@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.