Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

API client generator template uses deprecated syntax for regular expressions

Aberta
#143 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
52/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
api, tooling

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

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de CyberSource/cybersource-rest-client-python

Todas as issues de CyberSource/cybersource-rest-client-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.