feat: add shared utilities module core/utils/utils.py#52
Draft
feat: add shared utilities module core/utils/utils.py#52
core/utils/utils.py#52Conversation
…fetch_data, and _get_user Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> Agent-Logs-Url: https://github.com/scieloorg/markapi/sessions/ca40b753-50d3-47d9-bb05-15f8bd3155ea
… document None return Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> Agent-Logs-Url: https://github.com/scieloorg/markapi/sessions/ca40b753-50d3-47d9-bb05-15f8bd3155ea
Copilot
AI
changed the title
[WIP] Add shared utilities to core module
feat: add shared utilities module Mar 24, 2026
core/utils/utils.py
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.
O que esse PR faz?
Centraliza utilidades reutilizáveis em
core/utils/utils.py: normalização de idiomas, chamadas HTTP com reintentos e resolução de usuários.language_iso(code)— normaliza códigos de idioma vialangcodes(e.g."pt-BR"→"pt"), retorna""para códigos inválidosfetch_data/NonRetryableError— re-exportados decore.utils.requester(backoff exponencial min=1s, max=5s, 5 intentos;NonRetryableErrorem HTTP 4xx)_get_user(request, username, user_id)— centraliza lógica duplicada dexml_manager/tasks.py; resolve porrequest.user_id, fallback auser_idouusernameAdiciona
langcodes==3.5.1emrequirements/base.txt.Onde a revisão poderia começar?
core/utils/utils.pyComo este poderia ser testado manualmente?
Os 11 testes cobrem normalização de idiomas (códigos válidos, inválidos, None, vazio) e resolução de usuário (por
request.user_id, fallbackuser_id, fallbackusername, prioridade).Algum cenário de contexto que queira dar?
_get_userjá existia emxml_manager/tasks.py(linha 30). A implementação aqui é idêntica — chamaget_user_model()de forma lazy dentro da função para evitar problemas de importação circular.fetch_dataeNonRetryableErrorjá existem emcore/utils/requester.pycom toda a lógica de reintentos; este módulo apenas os re-exporta como ponto de entrada unificado.Screenshots
N/A
Quais são tickets relevantes?
Referências
Original prompt
core#48🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.