willthames / kubernetes-validate

Other
45 stars 5 forks source link

Add type hints #16

Closed paketb0te closed 2 years ago

paketb0te commented 2 years ago

Hi @willthames,

I recently stumbled upon this project and think its very useful, so I wanted to improve it a little bit by adding type hints :)

I also changed the module path for JsonDecodeError and RefResolutionError since my IDE complained about that - but maybe that changed in a recent python version, not sure (I used 3.10.6). Feel free to undo if this breaks something.

willthames commented 2 years ago

@paketb0te thanks for the type hints, they’ll be really helpful. Some of your indentation changes break pep8, if you can fix those we’ll see how the functional tests fare

paketb0te commented 2 years ago

I fixed the indentation - maybe using a formatter like black for the project could prevent such accidental style inconsitencies in the future?

paketb0te commented 2 years ago

@willthames I was not aware that this project is also supporting python 2.7 :smile:

TBH I am not quite sure how to resolve this - I tried using the backport of the typing package, but that did not let me use the PEP484 syntax either. It appears that to make type hints work with 2.7, we'd have to use this special comment syntax (which I personally find a bit odd to use): Suggested syntax for Python 2.7 and straddling code.

Since python 2.7 is officially deprecated for almost two years... do we even need to keep backwards compatibility?

willthames commented 2 years ago

If you want to remove 2.7 from tox that's absolutely fine - as you say it's 2 years past EOL

paketb0te commented 2 years ago

@willthames I removed 2.7 from tox and added 3.{8,10} instead :grinning: I also included mypy for static type checking.

willthames commented 2 years ago

@paketb0te thanks for this.

As dropping support for python 2.7 is technically a breaking change, I'll update this repo to also support kubernetes 1.25 and then release this as 1.25.0 rather than do a minor version bump of 1.24