pamelafox / pamelafox/axe-playwright-python

`generate_report()` sometimes gives `TypeError: sequence item 0: expected str instance, list found`

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
30
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
For some, but not all, reports, I'm seeing this error:

    def __violation_report(self, violation: dict, template: Template) -> str:
        nodes_str = ""
        for num, node in enumerate(violation["nodes"], start=1):
>           targets = ", ".join(node["target"])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
E           TypeError: sequence item 0: expected str instance, list found

To Reproduce

Steps to reproduce the behavior:

  1. check out: https://github.com/pycascades/pycascades-2026/tree/39a2096a0edda50c3161cba6b5be232e87b462a6
  2. uv run --with-requirements tests/requirements.txt pytest tests

Expected behavior
When findings are found, the assert here should print the findings

Logs
As a workaround, I dumped the results here:
results.txt

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/test_axe.py at the assert around line 104 and reproduce the failure using uv run --with-requirements tests/requirements.txt pytest tests. Trace generate_report() into __violation_report, where joining node["target"] raises the TypeError. Done means findings print as expected and the test suite passes for reports containing these nodes.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
accessibility, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.