Skip to content

Cyclic imports between app/desktop/server/core flagged by pylint (R0401) #42

Open

Description

@falbany

pylint src/profiles reports 16 cyclic-import warnings rooted in profiles.app reaching into every layer while those layers (or their shared models) are also imported transitively from it. Representative chain:

profiles -> profiles.app -> profiles.desktop.lifecycle -> profiles.server.app
         -> profiles.server.routes.scan -> profiles.core.processing.scanner
         -> profiles.core.config.service -> profiles.core.config.matcher
         -> profiles.core.config.models

It works today because the cycles close on import-order luck (module-level imports at the bottom of app.py, lazy imports elsewhere), but it violates the AGENTS.md boundary rule ("Aucune dépendance circulaire entre modules") and makes refactoring fragile.

Likely levers:

  • app.py is the hub: extract the server bootstrap wiring (routes needing server_state, static mount, port discovery) into a dedicated bootstrap module so app.py only calls it, instead of importing route modules transitively.
  • core.config.models is imported by everything including app — keep it dependency-free (the cycle enters through service/matcher chains).
  • Consider making profiles/__init__ (which resolves __version__) not import subpackages.

Acceptance: pylint src/profiles reports zero R0401 without new import-outside-toplevel workarounds beyond the documented lazy imports.

Activity

  1. added
    code-quality
    tech-debt
    on Oct 30, 2026
  2. added this to the v1.0.0 milestone on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-qualitytech-debt

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions