Apply ruff rules#42
Merged
love-apples merged 19 commits intolove-apples:mainfrom Feb 18, 2026
Merged
Conversation
…тации типов в функциях to_ms и from_ms
…авила ruff для группы PTH
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request applies ruff linting rules to modernize and standardize the codebase. The changes primarily focus on code formatting, type hint modernization, and implementing Python best practices without altering the core functionality.
Changes:
- Modernized type hints to use Python 3.10+ union syntax (
|instead ofUnion,X | Noneinstead ofOptional[X]) - Added keyword-only argument separators (
*) to functions with boolean flags and optional parameters - Refactored code for better readability (simplified nested conditions, used list comprehensions, added
contextlib.suppress) - Improved error handling with proper exception chaining (
from e) - Replaced
os.pathusage withpathlib.Pathfor file operations - Enhanced test assertions with
matchparameter inpytest.raises - Reformatted multi-line comments and docstrings for better line wrapping
Reviewed changes
Copilot reviewed 114 out of 114 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added extensive ruff linting rules configuration with per-file ignores |
| tests/test_types.py | Removed unnecessary pass statement from empty test method |
| tests/test_messagecallback_none.py | Added match parameter to pytest.raises for better error validation |
| tests/test_message_body_none.py | Added match parameter to pytest.raises for all test cases |
| tests/test_dispatcher.py | Reformatted multi-line comment |
| tests/test_chats_timestamps.py | Added pydantic_core import, improved exception handling and comment formatting |
| tests/test_bot.py | Updated function calls to use keyword arguments |
| tests/conftest.py | Added contextlib.suppress import, improved comment formatting and error handling |
| maxapi/utils/* | Modernized type hints, improved error handling with exception chaining |
| maxapi/types/* | Converted all type hints to modern syntax, moved imports to TYPE_CHECKING blocks |
| maxapi/methods/* | Modernized type hints, added keyword-only arguments, improved docstring formatting |
| maxapi/filters/* | Updated type hints, added keyword-only arguments, simplified conditional logic |
| maxapi/exceptions/* | Modernized type hints |
| maxapi/enums/* | Reformatted docstrings |
| maxapi/dispatcher.py | Major refactoring: modernized types, simplified logic, improved error messages |
| maxapi/context/* | Modernized type hints, removed unnecessary pass statements from abstract methods |
| maxapi/connection/base.py | Replaced os.path with pathlib.Path, improved error handling |
| maxapi/bot.py | Comprehensive modernization of type hints and added keyword-only arguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Этот pull request применяет правила линтинга ruff для модернизации и стандартизации кодовой базы. Изменения в первую очередь направлены на форматирование кода, модернизацию подсказок типов и внедрение лучших практик Python без изменения основной функциональности.
Изменения:
|вместоUnion,X | NoneвместоOptional[X])contextlib.suppress)from e)os.pathнаpathlib.Pathдля операций с файламиmatchвpytest.raisesP.S.: проработан не весь объём правил, часть закинул в TODO – и так достаточно жирный PR получился.