Skip to content

Get rid of pydantic and move data validation to standard dataclasses#2307

Open
francbartoli wants to merge 6 commits intogeopython:masterfrom
francbartoli:feature/remove-pydantic
Open

Get rid of pydantic and move data validation to standard dataclasses#2307
francbartoli wants to merge 6 commits intogeopython:masterfrom
francbartoli:feature/remove-pydantic

Conversation

@francbartoli
Copy link
Copy Markdown
Contributor

@francbartoli francbartoli commented Mar 28, 2026

Overview

This PR aims at removing pydantic from the core dependencies in favor of the standard dataclasses while offering the same level of data validation in the codebase. At the same time it improves the extensibility of the plugin system in order to write custom plugins for data validation with pydantic or other external validation libraries.
A new PluginContext dataclass has been added to pass dependencies in the plugin system. Downstream projects/forks can extend PluginContext via subclassing to integrate a custom validation logic.
The change has a minimal footprint on the plugin design because it guarantees backwards compatibility so existing pygeoapi instances can update with zero-risk impact.

Related Issue / discussion

Mainly discussed and agreed during the summit with the ultimate goal to get rid of pydantic and provide downstream data validation with custom pydantic-based (or similar tools) plugins

#1547
#1664

Additional information

A new RFC has been raised to voting about this design change

The plan to achieve the above goal is the following:

  • Extend the load_plugin in plugin.py method with an optional context based on a PluginContext dataclass
  • Refactor BaseProvider, BaseProcessor and BaseManager for backwards compatibility
  • Migrate APIRules to dataclass
  • Migrate TileSetMetadata to dataclass
  • Migrate MVTTilesJson to dataclass
  • Remove Pydantic from the dependencies

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@francbartoli francbartoli requested a review from a team March 28, 2026 18:25
@francbartoli francbartoli self-assigned this Mar 28, 2026
@francbartoli francbartoli added the enhancement New feature or request label Mar 28, 2026
@francbartoli francbartoli added this to the 0.24.0 milestone Mar 29, 2026
@francbartoli francbartoli marked this pull request as ready for review March 29, 2026 19:24
@francbartoli francbartoli force-pushed the feature/remove-pydantic branch from f5eec0c to 8e4f144 Compare March 29, 2026 19:27
@francbartoli
Copy link
Copy Markdown
Contributor Author

CI failures are not related to these changes

@webb-ben
Copy link
Copy Markdown
Member

Its not entirely clear to me how the introduction of PluginContext is coupled this closesly with the removal of pydantic. Furthermore I am not quite sure I understand the intended utility of it - perhaps this is a documentation question. Where / How would this be used?

@francbartoli
Copy link
Copy Markdown
Contributor Author

Its not entirely clear to me how the introduction of PluginContext is coupled this closesly with the removal of pydantic. Furthermore I am not quite sure I understand the intended utility of it - perhaps this is a documentation question. Where / How would this be used?

That's a very good question @webb-ben, I'm happy to document what's the intended usage downstream indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants