API client generator template uses deprecated syntax for regular expressions
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 52/100
Direção de pesquisa
Comece em generator/cybersource-python-template/api_client.mustache nas linhas referenciadas 424 e 429 e, em seguida, pesquise no template outras expressões regulares que usem strings não raw. Regenere o client se o workflow do projeto permitir e execute pytest no Python 3.12 ou 3.13; está concluído quando o client gerado não emitir mais esses SyntaxWarnings nem falhas relacionadas.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
Using the REST Client library in a project with Python >= 3.12 results in chattery SyntaxWarning messages, and sometimes pytest failures.
Starting in Python 3.6, strings that contain invalid escape sequences raise a DeprecationWarning. This includes regular strings that are used for regex expressions, as regex uses backslashed characters to denote operators/classes/etc. and those don't match up with escape sequences. DeprecationWarning is usually silent, but in 3.12 this was changed so that these now emit a SyntaxWarning, which isn't silent.
Compounding the issue is that pytest treats these as a failure when using Python 3.13.
More Info
The change is noted in the What's New for 3.12 here: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
See also the discussion here: https://github.com/python/cpython/issues/98401
I created a very simple test case that demonstrates the issue. It is available here: https://github.com/jkachel/cybersource-rest-error
The pytest error output is in a comment below to keep this issue from being too long.
Potential Fix
Regular expressions should use raw strings.
The main offenders seem to be here: https://github.com/CyberSource/cybersource-rest-client-python/blob/9d057e3bf85f9c8085394ec319bb2c74e843ffc7/generator/cybersource-python-template/api_client.mustache#L424
and in line 429 in the same file. The fix should be as simple as adding r to the start of those regex strings. I don't have a workflow set up for regenerating this client, and there may be other instances where this should be fixed that I don't know about, so I haven't tried to fix it.
Workaround
Client code can use the warnings library to filter SyntaxWarning when importing the CyberSource API client. Ex:
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=SyntaxWarning)
from CyberSource import ApiClient, OrdersApi
This resolves the issue in the short term but these should be fixed - as noted in the change, Python will (eventually) start emitting SyntaxError for these issues.
- Linguagem predominante
- Python
- Estrelas
- 24
- Forks
- 42
- Merge médio
- 3d 18h
- PRs com merge (30d)
- 1
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de CyberSource/cybersource-rest-client-python
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
loading configuration issueTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
CyberSource/cybersource-rest-client-python#177 · 1 comentário ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
CyberSource/cybersource-rest-client-python#168 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
CyberSource/cybersource-rest-client-python#156 · 1 comentário ·
Todas as issues de CyberSource/cybersource-rest-client-python
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
aws-samples/sample-per-model-bedrock#639 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
awslabs/visual-asset-management-system#937 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
project-codeflare/codeflare-sdk#1195 ·
Mantenedores costumam responder em até 1 dia
-
Bump numpy dependencyAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
pandas-dev/pandas-stubs#2051 ·
Mantenedores costumam responder em até 1 dia