Skip to content
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

exclude dirs in the pages folder that start with . or _ #2223

Merged
merged 5 commits into from
Sep 12, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Fixed

- [#2223](https://github.com/plotly/dash/pull/2223) Exclude hidden folders when building `dash.page_registry`.
- [#2182](https://github.com/plotly/dash/pull/2182) Fix [#2172](https://github.com/plotly/dash/issues/2172) Make it so that when using pages, if `suppress_callback_exceptions=True` the `validation_layout` is not set.
- [#2152](https://github.com/plotly/dash/pull/2152) Fix bug [#2128](https://github.com/plotly/dash/issues/2128) preventing rendering of multiple components inside a dictionary.
- [#2187](https://github.com/plotly/dash/pull/2187) Fix confusing error message when trying to use pytest fixtures but `dash[testing]` is not installed.
Expand Down
5 changes: 4 additions & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,10 @@ def verify_url_part(served_part, url_part, part_name):
def _import_layouts_from_pages(self):
walk_dir = self.config.pages_folder

for (root, _, files) in os.walk(walk_dir):
for (root, dirs, files) in os.walk(walk_dir):
dirs[:] = [
d for d in dirs if not d.startswith(".") and not d.startswith("_")
]
for file in files:
if (
file.startswith("_")
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/multi_page/pages/.no_import/no_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dash import register_page

register_page(__name__)

raise Exception("files in directories starting with . should not be imported")
4 changes: 4 additions & 0 deletions tests/integration/multi_page/pages/_no_import.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from dash import register_page

register_page(__name__)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh good catch, it wouldn't execute this file without register_page, would it!


raise Exception("files starting with _ should not be imported")