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

Add type hints and set up Mypy #58

Open
gmacon opened this issue Jun 30, 2020 · 5 comments
Open

Add type hints and set up Mypy #58

gmacon opened this issue Jun 30, 2020 · 5 comments

Comments

@gmacon
Copy link
Collaborator

gmacon commented Jun 30, 2020

OK, as I mentioned in #53 (comment), I've started thinking about setting up Mypy to try to catch some of these silly errors.

Here's what I've come up with so far:

  • Type hints were added in Python 3.5, but this project currently supports Python >=3.3. Would there be any objection to raising the minimum supported version to 3.5?
  • We should model the information read from the environment explicitly so that Mypy can know about it. It'd be handy to use Data Classes for that, which was added to Python in 3.7. We could still support Pythons 3.5 and 3.6 if we are prepared to add a dependency on Attrs for those old versions.
  • One of the things that makes Mypy hard to use in general is that lots of third-party packages don't have hints. I think we'll be OK on this front, since we don't have many third-party dependencies, and I noticed that dnspython does have hints when I was looking at it earlier.
@mschilli87
Copy link
Contributor

I think Debian Jessie ships Python 3.4 but support should end about now. I don't think distributions even further behind are going to package vpn-slice anytime soon so I guess dropping support for <3.5 won't cause much trouble.

@dlenski
Copy link
Owner

dlenski commented Jun 30, 2020

@gmacon This sounds great. I have no issues with Python 3.5 as the minimum requirement. Ubuntu 16.04 comes with Python 3.5, and it's olllllllllld.

Doesn't seem like attrs-vs-data-classes will be too hard to combine, and it is indeed probably worth supporting Python 3.5-3.6.

@gmacon
Copy link
Collaborator Author

gmacon commented Jun 30, 2020

I've realized that using data classes or attrs-as-data-classes requires Python 3.6 to get the variable annotation syntax. To keep 3.5, we'll need to use attrs unconditionally.

@gmacon
Copy link
Collaborator Author

gmacon commented Jul 3, 2020

I got a tad bit carried away earlier, and I did some data modeling on the environment, wrote a parser, and wrote tests for it. I've pushed that up to a branch, but I can open a WIP PR with it if folks would prefer that mechanism for discussing. The question here is basically "do I have the right data model?"

@dlenski
Copy link
Owner

dlenski commented Jul 13, 2023

A mere 3 years later (:sweat_smile:), I started trying to do something similar in the typing_annotations branch.

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

No branches or pull requests

3 participants