Skip to content

Fix pages modules is package #3315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Dash Testing

on:
push:
branches:
- dev
- master
pull_request:
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Fixed
- [#3279](https://github.com/plotly/dash/pull/3279) Fix an issue where persisted values were incorrectly pruned when updated via callback. Now, callback returned values are correctly stored in the persistence storage. Fix [#2678](https://github.com/plotly/dash/issues/2678)
- [#3298](https://github.com/plotly/dash/pull/3298) Fix dev_only resources filtering.
- [#3315](https://github.com/plotly/dash/pull/3315) Fix pages module is package check.

## Added
- [#3294](https://github.com/plotly/dash/pull/3294) Added the ability to pass `allow_optional` to Input and State to allow callbacks to work even if these components are not in the dash layout.
Expand Down
10 changes: 4 additions & 6 deletions dash/_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ def _infer_path(module_name, template):


def _module_name_is_package(module_name):
file_path = sys.modules[module_name].__file__
return (
file_path
and module_name in sys.modules
and Path(file_path).name == "__init__.py"
)
if module_name not in sys.modules:
return False
file = sys.modules[module_name].__file__
return file and file.endswith("__init__.py")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this return empty string rather than a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's usage is in a condition here:

if _module_name_is_package(CONFIG.name):



def _path_to_module_name(path):
Expand Down
Loading