You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, for the sake of completing the pipeline, we have ignored certain mypy errors. We need to work on a solution in order to make our code implementation compatible with mypy standards without ignoring these lines.
Suggestion:
The majority errors are due to the class-based implementation of foca in order to access it as a property of the Flask Config class. Hence one recommendation is to make the Foca app somehow a parent of the Connexion app, in a similar way that the Connexion app is a parent of the Flask app. Or to extend the Flask app (inside the Connexion) in a way that it has a property foca of type Config.
Most of the remaining type: ignores (about 30 in foca/, 16 of them attr-defined) come from attaching the config as a dynamic attribute to Flask's Config and reading it via current_app.config.foca. This also fails under Connexion 3, where security and error handlers run outside a Flask context. Instead of subclassing Flask/Connexion, we would add typed, framework-agnostic access:
foca.get_config() -> Config: returns current_app.config.foca inside an app context, else the config of the most recently created FOCA app (module-level registry), else raises RuntimeError. app.app.config.foca stays for app code. Foca.conf is documented for use outside requests.
get_collection(db, collection) -> pymongo.collection.Collection replaces the repeated ...dbs[x].collections[y].client chains.
log_traffic reads method, path, protocol and remote address through one helper based on flask.request instead of connexion.request.environ, which no longer exists in Connexion 3 (C3 2.5).
One translation point _connexion_add_api_kwargs(spec) with a typed ConnexionOptions model (strict_validation, validate_responses, swagger_ui, serve_spec, swagger_ui_path, base_path, resolver, extra keys allowed) used by register_openapi and the permissions API, so only this function changes for Connexion 3 (C3 2.6).
Remaining ignores (PyJWT/cryptography typing) are fixed individually or justified with a comment.
Acceptance criteria
No type: ignore[attr-defined] for config.foca left in foca/; mypy passes in CI; remaining ignores have a reason comment.
Tests: get_config() inside and outside an app context, and without any app (error).
Test: log_traffic inside a real app request (not a mocked environ).
Test: ConnexionOptions from today's connexion: {options: {...}} produces the same add_api kwargs.
README and template recommend get_config().
Breaking changes
None expected; current_app.config.foca keeps working. SpecConfig.connexion becomes a typed model that still accepts the current keys.
Activity
uniqueg commentedon Oct 18, 2026
Refined proposal
Most of the remaining
type: ignores (about 30 infoca/, 16 of themattr-defined) come from attaching the config as a dynamic attribute to Flask'sConfigand reading it viacurrent_app.config.foca. This also fails under Connexion 3, where security and error handlers run outside a Flask context. Instead of subclassing Flask/Connexion, we would add typed, framework-agnostic access:foca.get_config() -> Config: returnscurrent_app.config.focainside an app context, else the config of the most recently created FOCA app (module-level registry), else raisesRuntimeError.app.app.config.focastays for app code.Foca.confis documented for use outside requests.get_collection(db, collection) -> pymongo.collection.Collectionreplaces the repeated...dbs[x].collections[y].clientchains.current_app.config.focauses (auth, errors, enforcement, permissions controllers, Celery factory).log_trafficreads method, path, protocol and remote address through one helper based onflask.requestinstead ofconnexion.request.environ, which no longer exists in Connexion 3 (C3 2.5)._connexion_add_api_kwargs(spec)with a typedConnexionOptionsmodel (strict_validation,validate_responses,swagger_ui,serve_spec,swagger_ui_path,base_path,resolver, extra keys allowed) used byregister_openapiand the permissions API, so only this function changes for Connexion 3 (C3 2.6).Acceptance criteria
type: ignore[attr-defined]forconfig.focaleft infoca/;mypypasses in CI; remaining ignores have a reason comment.get_config()inside and outside an app context, and without any app (error).log_trafficinside a real app request (not a mockedenviron).ConnexionOptionsfrom today'sconnexion: {options: {...}}produces the sameadd_apikwargs.get_config().Breaking changes
None expected;
current_app.config.focakeeps working.SpecConfig.connexionbecomes a typed model that still accepts the current keys.Planned PR
11 (
refactor: typed config access, agnostic helpers).