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

Creation of unnecessary __init__.py files #25167

Closed
Saboti215 opened this issue Feb 29, 2024 · 2 comments · Fixed by #26045
Closed

Creation of unnecessary __init__.py files #25167

Saboti215 opened this issue Feb 29, 2024 · 2 comments · Fixed by #26045

Comments

@Saboti215
Copy link
Contributor

Description of the issue

I am using multiple self created pages inside my application. Since version 14, I encountered some issues with the automatic creation of __init__.py files in the pages directory. Each of my pages have multiple sub-directories to manage the files. One example page looks like this:

dashboard/
├── admin_card.js
├── config
│   ├── defaults.js
│   └── __init__.py        <-- not needed
├── dashboard.js
├── dashboard_widget.js
├── index.html
├── index.js
├── index.py
├── __init__.py
├── interface
│   ├── dashboard.py
│   └── __init__.py        <-- maybe not needed
└── styles
    ├── index.scss
    └── __init__.py        <-- not needed

But during bench migrate, frappe will automatically create __init__.py files in all of my sub directories. Since the init files are only needed for python modules, I want to get rid of them everywhere else.

Context information (for bug reports)

Output of bench version

erpnext 14.63.1
frappe 14.66.2

Steps to reproduce the issue

  1. Create a new page with multiple sub directories
  2. bench migrate
  3. __init__.py files will be generated in each sub directory.

Observed result

__init__.py files are generated in every sub directoy.

Expected result

__init__.py files should only be generated on the top-level directory of the page.

Stacktrace / full error message

/

Additional information

I think the issue is caused by the function get_pages_from_path in router.py. My suggestion is to just create the init-file inside the top-level directory. It could be easier to move this functionality out of the function get_pages_from_path, since regarding it's name it should only get the pages without creating anything.

@Saboti215 Saboti215 added the bug label Feb 29, 2024
Mutantpenguin added a commit to Mutantpenguin/frappe that referenced this issue Apr 18, 2024
These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes frappe#25167
ankush pushed a commit that referenced this issue Apr 22, 2024
* fix: 🐛 don't create __init__.py files when gathering pages

These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes #25167

* refactor: ⚰️ remove commented out code
mergify bot pushed a commit that referenced this issue Apr 22, 2024
* fix: 🐛 don't create __init__.py files when gathering pages

These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes #25167

* refactor: ⚰️ remove commented out code

(cherry picked from commit 0a4ee1d)

# Conflicts:
#	frappe/website/router.py
mergify bot pushed a commit that referenced this issue Apr 22, 2024
* fix: 🐛 don't create __init__.py files when gathering pages

These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes #25167

* refactor: ⚰️ remove commented out code

(cherry picked from commit 0a4ee1d)
ankush pushed a commit that referenced this issue Apr 22, 2024
…26090)

* fix: 🐛 don't create __init__.py files when gathering pages

These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes #25167

* refactor: ⚰️ remove commented out code

(cherry picked from commit 0a4ee1d)

# Conflicts:
#	frappe/website/router.py

Co-authored-by: Markus Lobedann <markus.lobedann@gmail.com>
ankush pushed a commit that referenced this issue Apr 22, 2024
…26091)

* fix: 🐛 don't create __init__.py files when gathering pages

These files are only necessary if any other *.py files exists in a pages folder. Apart from that, this functions purpose (by name) is to get pages, and not create any source code files.

closes #25167

* refactor: ⚰️ remove commented out code

(cherry picked from commit 0a4ee1d)

Co-authored-by: Markus Lobedann <markus.lobedann@gmail.com>
frappe-pr-bot pushed a commit that referenced this issue Apr 23, 2024
# [15.24.0](v15.23.0...v15.24.0) (2024-04-23)

### Bug Fixes

* 🐛 don't create __init__.py files when gathering pages ([#26045](#26045)) ([#26091](#26091)) ([285a30f](285a30f)), closes [#25167](#25167)
* allow setting dynamic filters for number cards even without developer mode ([8811e82](8811e82))
* Avoid permission check on unsaved doc ([#26027](#26027)) ([#26031](#26031)) ([334d353](334d353))
* dashboard link number color for timeless night ([#26058](#26058)) ([d6a060d](d6a060d))
* datepicker time row color for timeless night ([#26077](#26077)) ([ef2f3e2](ef2f3e2))
* filter select perm in get_doctypes_with_read (backport [#26037](#26037)) ([#26040](#26040)) ([2d7d38e](2d7d38e))
* filters on prepared report export ([627a0ed](627a0ed))
* **grid_row:** check child table dependent properties whenever a row is selected ([6ec64a8](6ec64a8))
* **grid:** ensure that `doc` itself is not null ([b4c9d40](b4c9d40)), closes [#25800](#25800)
* increase report limit ([#26102](#26102)) ([#26104](#26104)) ([8706dd8](8706dd8))
* limit select user to desk users by default ([#25843](#25843)) ([#25996](#25996)) ([374c75c](374c75c))
* only notify for modified greater than DB ([#26070](#26070)) ([#26071](#26071)) ([224d8aa](224d8aa))
* register faulthandler on true stderr only (backport [#26028](#26028)) ([#26034](#26034)) ([bb0f1be](bb0f1be))
* **report_view:** allow exporting all rows even if count is disabled ([0f65a23](0f65a23))
* **resolver:** handle werkzeug redirect exception ([3f9b5f3](3f9b5f3))
* runtime error during pot build ([#25991](#25991)) ([#25992](#25992)) ([58a133b](58a133b))
* strip redirect URIs for trailing whitespaces ([#26006](#26006)) ([#26008](#26008)) ([d543dd3](d543dd3))
* unknown charset windows-874 problem on incoming mail ([14e1a31](14e1a31))

### Features

* add copy to clipboard on read only code fields ([62f09f7](62f09f7))
* enable dynamic filters for standard number cards ([ba2f70a](ba2f70a))
* gettext translations (v15 port) ([#25982](#25982)) ([0189bb2](0189bb2))
* System Health Report (backport [#26046](#26046)) ([#26085](#26085)) ([7b8a923](7b8a923))
* What's New ([#25986](#25986)) ([fc0ab40](fc0ab40))
@frappe-pr-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 15.24.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

frappe-pr-bot pushed a commit that referenced this issue Apr 30, 2024
# [14.73.0](v14.72.0...v14.73.0) (2024-04-30)

### Bug Fixes

* 🐛 don't create __init__.py files when gathering pages ([#26045](#26045)) ([#26090](#26090)) ([84fbc40](84fbc40)), closes [#25167](#25167)
* add missing impl for is_column_missing (backport [#26225](#26225)) ([#26226](#26226)) ([b5abe55](b5abe55))
* allow setting dynamic filters for number cards even without developer mode ([7d5b443](7d5b443))
* avoid perm error on dashboard chart ([#26150](#26150)) ([#26156](#26156)) ([6231e1d](6231e1d))
* calendar in Arabic (backport [#26213](#26213)) ([#26215](#26215)) ([67530e3](67530e3)), closes [#26207](#26207)
* compute modal title server side ([#26191](#26191)) ([760ff72](760ff72))
* Dirty form when grid rows are moved ([#26230](#26230)) ([#26233](#26233)) ([ce4fa2a](ce4fa2a))
* filter select perm in get_doctypes_with_read (backport [#26037](#26037)) ([#26039](#26039)) ([e889691](e889691))
* frappe.template.compile(...) is not a function ([#26125](#26125)) ([#26126](#26126)) ([ea5d7b7](ea5d7b7))
* german translations ([#26219](#26219)) ([a40dfdd](a40dfdd))
* **grid_row:** check child table dependent properties whenever a row is selected ([caabb79](caabb79))
* **grid:** ensure that `doc` itself is not null ([a2b61eb](a2b61eb)), closes [#25800](#25800)
* handle case where mimetype is None ([#26131](#26131)) ([#26132](#26132)) ([cc3b654](cc3b654))
* handle null in CSV preview ([#26154](#26154)) ([2e2649b](2e2649b))
* register faulthandler on true stderr only (backport [#26028](#26028)) ([#26033](#26033)) ([45630fe](45630fe))
* rename fields for html, col, section, etc. ([#26188](#26188)) ([1a2411c](1a2411c))
* Renaming when doctype is used as a virtual link docfield fails ([#26025](#26025)) ([#26118](#26118)) ([eea6509](eea6509))
* **report builder:** responsive footer ([#26222](#26222)) ([#26223](#26223)) ([4f0bcf1](4f0bcf1))
* **report_utils:** ensure that delimiter and separator can't be empty ([5301516](5301516))
* **report_view:** allow exporting all rows even if count is disabled ([c0cf52f](c0cf52f))
* retry count per doc instead of global ([#26159](#26159)) ([#26160](#26160)) ([0d6ff95](0d6ff95))
* strip redirect URIs for trailing whitespaces ([#26006](#26006)) ([#26007](#26007)) ([aefc6f9](aefc6f9))
* unknown charset windows-874 problem on incoming mail ([86eff33](86eff33))
* **UX:** warning when printing unsaved documents ([#26229](#26229)) ([#26231](#26231)) ([1530618](1530618))
* web form filtering ([#26122](#26122)) ([#26123](#26123)) ([519fec5](519fec5))

### Features

* enable dynamic filters for standard number cards ([3a4eeb9](3a4eeb9))
* **grid:** Add shift-click for selecting multiple rows ([c9d227a](c9d227a))
* **grid:** Extend clickable area of checkboxes ([2664cf3](2664cf3))
* let users unlock stuck documents (backport [#24782](#24782)) ([#25225](#25225)) ([e58ea03](e58ea03))
* limit oauth client to roles (backport [#26193](#26193)) ([#26195](#26195)) ([5b7bccf](5b7bccf))
@frappe-pr-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 14.73.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants