Skip to content

Fix pages path inference when a module name contains the pages folder name - #4169

Open
thejesh23 wants to merge 3 commits into
plotly:devfrom
thejesh23:fix/pages-infer-path-substring
Open

thejesh23 wants to merge 3 commits into
plotly:devfrom
thejesh23:fix/pages-infer-path-substring

Conversation

@thejesh23

Copy link
Copy Markdown

Fixes #4168.

_infer_path split the module name on the pages folder name as a substring, so pages/landing_pages.py got /, pages/subpages/report.py got /report, and two such pages made every request fail with a duplicate path error. It now matches the folder name only as a whole dotted part of the module name (still the last match, as before), so those pages get /landing-pages and /subpages/report. Module names where the folder name is already a whole part (all existing test cases, including dotted folder names like custom.pages) keep the same path.

Tests: three new cases in tests/unit/pages/test_pages.py::test_infer_path and test_pain001 in tests/integration/multi_page/test_pages_infer_path.py (a views/ pages folder with overviews.py and reviews/latest.py, opened with dash_duo). Both fail on dev (views.overviews gets /, views.reviews.latest gets /latest) and pass with the fix. pytest tests/unit and tests/integration/multi_page pass locally on Python 3.14 (apart from pala006, which needs the locally unbuilt dash_test_components); black, flake8 and pylint are clean on Python 3.10.

Contributor Checklist

  • This PR targets dev (fix or chore) or next (feature, new API, breaking change), see Which branch to target
  • I have broken down my PR scope into the following TODO tasks
    • match the pages folder name as a whole module part in _infer_path
    • unit and integration tests
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md

Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Pages: inferred path is wrong when a page module name contains the pages folder name

1 participant