Skip to content

Apply ruff rules#42

Merged
love-apples merged 19 commits intolove-apples:mainfrom
Olegt0rr:chore/add-ruff-rules
Feb 18, 2026
Merged

Apply ruff rules#42
love-apples merged 19 commits intolove-apples:mainfrom
Olegt0rr:chore/add-ruff-rules

Conversation

@Olegt0rr
Copy link
Copy Markdown
Collaborator

@Olegt0rr Olegt0rr commented Feb 17, 2026

Этот pull request применяет правила линтинга ruff для модернизации и стандартизации кодовой базы. Изменения в первую очередь направлены на форматирование кода, модернизацию подсказок типов и внедрение лучших практик Python без изменения основной функциональности.

Изменения:

  • Модернизированы подсказки типов для использования синтаксиса union в Python 3.10+ (| вместо Union, X | None вместо Optional[X])
  • Добавлены разделители аргументов только по ключевому слову (*) в функциях с булевыми флагами и опциональными параметрами
  • Рефакторинг кода для улучшения читаемости (упрощены вложенные условия, использованы list comprehensions, добавлен contextlib.suppress)
  • Улучшена обработка ошибок с правильной цепочкой исключений (from e)
  • Заменено использование os.path на pathlib.Path для операций с файлами
  • Усилены утверждения в тестах с параметром match в pytest.raises
  • Переформатированы многострочные комментарии и докстринги для лучшего переноса строк

P.S.: проработан не весь объём правил, часть закинул в TODO – и так достаточно жирный PR получился.

Copilot AI review requested due to automatic review settings February 17, 2026 17:34
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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 of Union, X | None instead of Optional[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.path usage with pathlib.Path for file operations
  • Enhanced test assertions with match parameter in pytest.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.

@Olegt0rr Olegt0rr marked this pull request as draft February 18, 2026 07:11
@Olegt0rr Olegt0rr marked this pull request as ready for review February 18, 2026 12:52
@love-apples love-apples merged commit 1a50eb5 into love-apples:main Feb 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants