Skip to content

Introduce explicit typing for type_map across datasources #38

@zurfjereluhmie

Description

@zurfjereluhmie

The type_map parameter in PostGISDataSource (and the maps exported from the built-in datasources) is currently typed as dict[str, list[str]] | None. The keys are free-form strings, giving no editor support, no static guarantee that only known etter type names are used, and no shared contract that datasources can implement against.

Current situation

Location Current type
PostGISDataSource.__init__ (postgis.py introduced in #25 ) dict[str, list[str]] | None
SwissNames3DSource.OBJEKTART_TYPE_MAP (swissnames3d.py) dict[str, list[str]]
IGNBDCartoSource.IGN_BDCARTO_TYPE_MAP (ign_bdcarto.py) dict[str, list[str]]

The canonical set of normalized type names is defined in location_types.py

Problems

  1. No static key validation. A caller can pass {"lac": [...]} instead of {"lake": [...]} and the error only surfaces at runtime (silently: features are returned with the type "lac" instead of being filtered correctly).

  2. No IDE auto-complete. Because keys are str, editors cannot suggest valid type names when constructing a custom map.

  3. No shared contract. PostGISDataSource accepts the same shape as the built-in maps but there is no interface enforcing this, so future datasources can diverge.

  4. OBJEKTART_TYPE_MAP / IGN_BDCARTO_TYPE_MAP do not declare intent. Their return type dict[str, list[str]] does not communicate that the keys must be etter type names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions