Skip to content

try: from .x / except ImportError: from x everywhere #93

@pmaasz

Description

@pmaasz

128 occurrences across 43 files. This pattern is what you write when you're not sure whether the module is being imported as part of a package or as a top‑level script. The cost is:

  • Every import does filesystem work twice.
  • Genuine ImportErrors inside your own code are swallowed on the first try and get reported wrong on the second.
  • Static analysis tools (pylint, mypy) go crazy.

Fix the packaging (you already have setup.py), run the app as python -m openlens, and delete all of them.

4.6 services.py is present but underused

src/services.py defines LensService / CalculationService / MaterialDatabaseService but most of its methods are bypassed:

  • openlens.py:123 and the widget handlers mutate Lens directly and then call _save_to_database() on the main window.
  • src/desensitization.py:156 and src/global_optimizer.py:119,219 call optimize_simplex(...) directly despite AGENTS.md stating "always use optimize()".

Either delete the service layer or actually route work through it. Right now it is a stub that future readers assume is real.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions