-
Notifications
You must be signed in to change notification settings - Fork 1
Simplify Pydantic version checks and reorganize schemas #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request modernizes the beans_logging package by consolidating configuration models into a new config.py module and standardizing on Pydantic v2. The refactor replaces the old schemas.py with improved configuration classes, removes Pydantic version compatibility code, and introduces a new utility function for generating slugified names.
- Replaced
schemas.pywith a unifiedconfig.pycontaining modernized Pydantic v2 models - Removed conditional Pydantic v1/v2 compatibility code throughout the codebase
- Updated utility functions to use a new
get_slug_namefunction instead of separateget_app_nameandget_default_logs_dirfunctions
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/beans_logging/schemas.py | Completely removed old configuration models (173 lines deleted) |
| src/beans_logging/config.py | Added new unified configuration module with modern Pydantic v2 models |
| src/beans_logging/_utils.py | Updated imports, removed Pydantic compatibility code, replaced utility functions |
| src/beans_logging/_base.py | Updated imports and removed Pydantic version checks |
| src/beans_logging/init.py | Updated imports to reference new config module and renamed constants |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| stream: StreamConfigPM = Field(default_factory=StreamConfigPM) | ||
| file: FileConfigPM = Field(default_factory=FileConfigPM) | ||
| intercept: InterceptConfigPM = Field(default_factory=InterceptConfigPM) | ||
| extra: ExtraConfigPM | None = Field(default_factory=ExtraConfigPM) |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra field has inconsistent typing. It's typed as ExtraConfigPM | None but uses default_factory=ExtraConfigPM which will never produce None. Either change the type to ExtraConfigPM or use default=None if None values are intended.
| extra: ExtraConfigPM | None = Field(default_factory=ExtraConfigPM) | |
| extra: ExtraConfigPM = Field(default_factory=ExtraConfigPM) |
|
|
||
| return ( | ||
| os.path.splitext(os.path.basename(sys.argv[0]))[0] | ||
| if not file_path: |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition if not file_path: will be True for empty strings, which may not be the intended behavior. Consider using if file_path is None: to only handle the case where no path is explicitly provided.
| if not file_path: | |
| if file_path is None: |
This pull request refactors the configuration handling in the
beans_loggingpackage, primarily by replacing the oldschemas.pyconfig models with a new, unifiedconfig.pyimplementation. It also cleans up compatibility code for different Pydantic versions, simplifies imports, and introduces a new utility function for slugifying file names. These changes modernize the codebase, improve maintainability, and streamline configuration management.Configuration Model Refactor:
schemas.pywith a newconfig.pymodule, consolidating all configuration Pydantic models and validators into a single file. The new models use modern Pydantic v2 features and naming conventions (e.g.,LoggerConfigPM,StreamConfigPM). (src/beans_logging/config.py,src/beans_logging/schemas.py) [1] [2]Import and Naming Consistency:
config.pymodels and renamed internal constants modules from_conststo_constantsfor clarity. (src/beans_logging/__init__.py,src/beans_logging/_base.py,src/beans_logging/_utils.py) [1] [2] [3]Pydantic Compatibility Cleanup:
validate_call,model_validator, andfield_validator). (src/beans_logging/_base.py,src/beans_logging/_utils.py) [1] [2]Utility Function Update:
get_slug_namefunction to_utils.pyfor generating slugified names from file paths, replacing the previousget_app_nameandget_default_logs_dirfunctions. (src/beans_logging/_utils.py)Documentation and Type Improvements:
LoggerLoaderconstructor. (src/beans_logging/_base.py)