Skip to content

PY: make python-us-core example mypy --strict clean #181

Description

@ryukzak

Follow-up from #180. That PR widened the us-core mypy scope to the whole example dir but kept the relaxed `mypy.ini`. Moving to `--strict` is a larger, separate effort.

Running `mypy --strict --config-file mypy.ini .` on `examples/python-us-core` currently reports 250 errors.

Generated code — 171 (needs generator changes)

  • `no-any-return` (87): getters declared with a concrete return type but `return item` / `model_dump()` yields `Any` — needs casts or typed helpers.
  • `type-arg` (77): bare generics in output — `dict` (flat slice form) and FHIR base types without their `[str]` param (`Coding`, `CodeableConcept`, …) — generator must emit type args.
  • `unused-ignore` (7): stale ignores in generated code.

Hand-written tests/demo — 79

  • `no-untyped-def` (60): test/demo functions need return annotations.
  • `unused-ignore` (10), `attr-defined` (5, mostly `init` not re-exporting profile classes), `comparison-overlap` (4).

Notes

  • The other two python examples (`python-r4`, `python-fhirpy`) already run `mypy --strict .`; this would bring us-core in line.
  • The big two (`type-arg`, `no-any-return`) are the bulk and require generator work in `src/api/writer-generator/python/`.
  • Possible incremental step before full strict: enable `warn_unused_ignores` and `disallow_untyped_defs` for test files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions