fix: retornar None em vez de string vazia quando padrão não encontrad…#202
Open
MuriloM676 wants to merge 1 commit intofazedordecodigo:developfrom
Open
fix: retornar None em vez de string vazia quando padrão não encontrad…#202MuriloM676 wants to merge 1 commit intofazedordecodigo:developfrom
MuriloM676 wants to merge 1 commit intofazedordecodigo:developfrom
Conversation
fazedordecodigo#191) - Alterado get_pattern para retornar None quando padrão não existe - Adicionado teste para validar comportamento com padrão inexistente - Evita validações falso-positivas causadas por string vazia
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.
Descrição
Corrige o bug onde a função
get_pattern()retornava uma string vazia ("") em vez deNonequando um padrão de regex não era encontrado no dicionárioREGEX_PATTERNS. Este comportamento causava validações falso-positivas, pois uma string vazia pode fazer match com certos padrões regex, quando deveria retornarNonepara indicar que o padrão não existe.Mudanças Propostas
get_pattern()emflunt/localization/flunt_regex_patterns.pypara retornarNonequando padrão não existestr | Pattern[str]parastr | Pattern[str] | Nonetest_should_return_none_for_unknown_patternpara validar comportamento com padrão inexistenteChecklist de Revisão
Comentários Adicionais (opcional)
Este fix é importante para garantir a integridade das validações. O código existente que usa
get_pattern()já está preparado para lidar corretamente comNone, conforme verificado em:email_validation_contract.pycredit_card_validation_contract.pyurl_validation_contract.pyTodos esses arquivos já possuem verificações
if pattern is None:nas funções helper com cache, então a mudança é totalmente retrocompatível e não quebra nenhuma funcionalidade existente.Issue Relacionada
Closes #191