pyproject.toml: a comment or `]` inside a pytest list drops entries

Aberta Para iniciantes
#158 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
86/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
testing

Direção de pesquisa

Comece em src/repo/adapters/python.ts, nas funções readPytestSettings e splitList, e depois leia o caso some_function() em tests/repo/python-adapter.test.ts. Adicione cobertura para os três exemplos TOML e para uma lista em várias linhas com vírgula final; faça com que uma entrada incerta defina settings.unreadable. Execute npm test e confirme que os valores da lista são preservados e que o fallback para entradas ilegíveis está coberto.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

adapter bug good first issue

readPytestSettings in src/repo/adapters/python.ts reads python_files, testpaths and pythonpath from [tool.pytest.ini_options] with a regex. The regex takes everything up to the first ], and splitList splits it on whitespace and commas. TOML comments and brackets inside strings both break this:

[tool.pytest.ini_options]
python_files = [
  "test_*.py",  # see [docs]
  "check_*.py",
]

Today this returns ["test_*.py", "#", "see", "[docs"], which drops check_*.py. With the comment # unit instead, it returns ["test_*.py", "#", "unit", "check_*.py"]. testpaths = ["tests/[a]", "integration"] returns ["tests/[a"], which drops integration.

Done when:

  • Comments outside strings are ignored, and a ] or , inside a quoted string stays part of the value. Splitting the list into quoted strings works better than splitting on whitespace.
  • Anything the reader can't parse with certainty sets settings.unreadable, as a non-literal value already does (see the some_function() case in the test). DiffCI then runs the full suite, which is safe. Never guess.
  • tests/repo/python-adapter.test.ts has cases for the three examples above, plus a multi-line list with a trailing comma.

New to DiffCI? See CONTRIBUTING.md: add a synthetic fixture, run npm test, and sign off commits with git commit -s. Comment here to claim the issue.

Linguagem predominante
TypeScript
Estrelas
0
Forks
4
Merge médio
18h 41min
PRs com merge (30d)
48

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

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 DiffCI/core

Todas as issues de DiffCI/core

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

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