docs: исправлен пример lazy ref — is not None вместо truthiness#103
Merged
love-apples merged 1 commit intolove-apples:feat/fetch-without-auto-requestsfrom Apr 9, 2026
Conversation
Pending LazyRef является falsy (bool = False), поэтому паттерн `if event.chat` не вызовет fetch(). Исправлено на `is not None`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
love-apples
added a commit
that referenced
this pull request
Apr 13, 2026
* feat: fetch для user и chat при auto_requests=False * Добавлены тесты для lazy fetch и обработки None в обновлениях * docs: исправлен пример lazy ref — проверка через is not None (#103) Pending LazyRef является falsy (bool = False), поэтому паттерн `if event.chat` не вызовет fetch(). Исправлено на `is not None`. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: обновление проверки chat и from_user. callable в isinstance * feat: унификация полей * feat: добавлено блокирование для безопасной конкурентной загрузки в LazyRef * Update maxapi/bot.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: добавлено логирование ошибок при получении участника чата в _resolve_from_user * feat: обновление обработки событий для безопасного получения chat и from_user --------- Co-authored-by: Bishon <164760691+bish-x@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Описание
Исправлен нерабочий паттерн в документации для
auto_requests=False.Проблема
Pending
LazyRefявляется falsy (bool(ref)=False), поэтому паттерн:никогда не вызовет
fetch()— условиеif event.chatвернётFalseдля lazy ref, и пользователь всегда получитNone.Исправление
Проверка
is not Noneкорректно отличает "lazy ref существует" от "ref не назначен".Также добавлен комментарий в коде, объясняющий почему нужен
is not None.Рекомендуемый подход
Основной API остаётся
await event.fetch_chat()— он работает корректно во всех случаях.