Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of typing hints #970

Open
eumetsat-usc-das opened this issue Jan 30, 2025 · 3 comments
Open

Addition of typing hints #970

eumetsat-usc-das opened this issue Jan 30, 2025 · 3 comments

Comments

@eumetsat-usc-das
Copy link

Dear OWSLib team, thanks a lot for the effort already put into the library. It has become part of what we suggest our users to use to interact with our OGC services.

Now we are considering leveraging the library in one of our projects but we have requirements in place that force us to use type checking using mypy. We can try and add the typing on our side and then prepare a pull request but I wanted to check with you before starting.

Is typing hints something you'd consider having (and then maintaining) in OWSLib?

@geographika
Copy link
Contributor

@eumetsat-usc-das

Personally, I'm not against adding type hints. It definitely improves the documentation of the library, and makes it easier to work with in code editors. Although, after having updated a few codebases, I've yet to find any errors caused by incorrect types found using mypy (likely due to string test suites already in place). It seems a slightly strange requirement that any project dependency requires type checking - it is easy to ignore certain libraries with mypy.

A few other thoughts:

  • adding types in one pull request would be huge, it would be easier to review at least on a module by module basis, with a pull request for each. An initial small pull request to add types would be useful to work out a process. Adding types gradually would be my preference.
  • a new GitHub Action would need to be added to check the types automatically on pull requests (see example at Add type hints to the codebase geographika/mappyfile#189)
  • prior to any huge update to the codebase it may be useful to reformat the project using black
  • The review process is going to be fairly laborious, if OWSLib is a key part of the project it would be worth considering a donation to https://www.osgeo.org/sponsors/ to help with maintenance of the library

I'll raise this discussion with the other maintainers.

@tomkralidis
Copy link
Member

+1 for type hinting, and thanks for offering this contribution. We've done this with most of owslib.ogcapi given it is recent development. +1 with @geographika's suggestion of smaller PRs to better manage this set of updates.

@geographika
Copy link
Contributor

@eumetsat-usc-das - there's general agreement this would be a good addition to the project, so whenever you are ready, please submit an initial pull request for a file or module with type hints.

See https://github.com/geopython/OWSLib/blob/master/owslib/ogcapi/features.py for a file where types are already in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants