[PR #163] [MERGED] [cleanup] Import every name from its canonical module #165

Closed
opened 2026-10-13 19:48:13 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/163
Author: @Glitchy-Sheep
Created: 8/19/2026
Status: ✅ Merged
Merged: 8/19/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: chore/canonical-imports


📝 Commits (1)

  • ae14b17 chore: Import every name from its canonical module

📊 Changes

10 files changed (+17 additions, -23 deletions)

View changed files

📝 boosty_downloader/src/application/di/app_environment.py (+1 -1)
📝 boosty_downloader/src/application/mappers/__init__.py (+0 -3)
📝 boosty_downloader/src/application/mappers/external_video.py (+1 -1)
📝 boosty_downloader/src/application/mappers/file.py (+1 -1)
📝 boosty_downloader/src/application/mappers/html_converter.py (+1 -1)
📝 boosty_downloader/src/application/mappers/image.py (+1 -1)
📝 boosty_downloader/src/application/mappers/ok_boosty_video.py (+1 -1)
📝 boosty_downloader/src/application/use_cases/check_total_posts.py (+1 -1)
📝 boosty_downloader/src/application/use_cases/download_single_post.py (+6 -9)
📝 boosty_downloader/src/application/use_cases/download_specific_post.py (+4 -4)

📄 Description

[cleanup] Import every name from its canonical module

Summary

Second cleanup PR (audit этап 2). Pure import mechanics, zero behavior change: every name now comes from the module that defines it, and the one real import cycle in the package is gone.

Problem

  • Names travelled through unrelated modules: BoostyAPIClient was imported via a sibling use case, an application error via another use case, a domain type via the HTML converter - deleting an "unused" import line in one file silently broke another
  • mappers/__init__ and post_mapper imported each other; the cycle survived only thanks to CPython's partial-init fallback, one reordering away from a hard ImportError
  • Getting the RichLogger type dragged in logger_instances, a module that mutates sys.stdout at import time

Fix

  • Transitive imports replaced with canonical ones across 10 files; chunk types come from post_data_chunks, the domain.post union hub keeps only Post and the unions
  • The cycle is removed at its single edge: the mappers facade no longer re-exports post_mapper; post_mapper keeps the readable mappers.to_domain_* namespace style, and its consumers import it from its own module
  • RichLogger comes from loggers.base - no import-time side effects for a type

Verification

  • task ci green: checks, 174 tests + 1 xfail, e2e, build
  • Both package-init orders for mappers verified explicitly - no cycle by construction
  • No changelog entry: internal mechanics only (ci/skip-changelog)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/163 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 8/19/2026 **Status:** ✅ Merged **Merged:** 8/19/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `chore/canonical-imports` --- ### 📝 Commits (1) - [`ae14b17`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/ae14b17294acc499187349c42c7681244c8dd184) chore: Import every name from its canonical module ### 📊 Changes **10 files changed** (+17 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `boosty_downloader/src/application/di/app_environment.py` (+1 -1) 📝 `boosty_downloader/src/application/mappers/__init__.py` (+0 -3) 📝 `boosty_downloader/src/application/mappers/external_video.py` (+1 -1) 📝 `boosty_downloader/src/application/mappers/file.py` (+1 -1) 📝 `boosty_downloader/src/application/mappers/html_converter.py` (+1 -1) 📝 `boosty_downloader/src/application/mappers/image.py` (+1 -1) 📝 `boosty_downloader/src/application/mappers/ok_boosty_video.py` (+1 -1) 📝 `boosty_downloader/src/application/use_cases/check_total_posts.py` (+1 -1) 📝 `boosty_downloader/src/application/use_cases/download_single_post.py` (+6 -9) 📝 `boosty_downloader/src/application/use_cases/download_specific_post.py` (+4 -4) </details> ### 📄 Description # [cleanup] Import every name from its canonical module ## Summary Second cleanup PR (audit этап 2). Pure import mechanics, zero behavior change: every name now comes from the module that defines it, and the one real import cycle in the package is gone. ## Problem - Names travelled through unrelated modules: `BoostyAPIClient` was imported via a sibling use case, an application error via another use case, a domain type via the HTML converter - deleting an "unused" import line in one file silently broke another - `mappers/__init__` and `post_mapper` imported each other; the cycle survived only thanks to CPython's partial-init fallback, one reordering away from a hard `ImportError` - Getting the `RichLogger` type dragged in `logger_instances`, a module that mutates `sys.stdout` at import time ## Fix - Transitive imports replaced with canonical ones across 10 files; chunk types come from `post_data_chunks`, the `domain.post` union hub keeps only `Post` and the unions - The cycle is removed at its single edge: the mappers facade no longer re-exports `post_mapper`; `post_mapper` keeps the readable `mappers.to_domain_*` namespace style, and its consumers import it from its own module - `RichLogger` comes from `loggers.base` - no import-time side effects for a type ## Verification - `task ci` green: checks, 174 tests + 1 xfail, e2e, build - Both package-init orders for `mappers` verified explicitly - no cycle by construction - No changelog entry: internal mechanics only (`ci/skip-changelog`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#165
No description provided.