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

Case classes #2

Closed
suned opened this issue Aug 10, 2019 · 1 comment
Closed

Case classes #2

suned opened this issue Aug 10, 2019 · 1 comment
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@suned
Copy link
Owner

suned commented Aug 10, 2019

Use mypy plugin to enable static checking of case classes (see pfun/case.py for a start).

Things that can be checked:

  • That all all cases are covered
  • That all cases return same value
  • That case arguments are of the correct type (t must correspond to match type, must be case subclasses, must all have the same base case)
  • That arguments to when and then are of the correct type

Other things that plugin must (should) do:

  • Handle CaseClass calls to dataclass to enable __init__ generation (maybe possible to use mypy dataclass plugin)
  • Make sure that each Case subclass has exactly one base case class.
@suned suned added the enhancement New feature or request label Aug 10, 2019
@suned suned added the wontfix This will not be worked on label Feb 17, 2021
@suned
Copy link
Owner Author

suned commented Feb 17, 2021

This is likely to be added to mypy at some point, especially given the structural pattern matching features in Python 3.1

@suned suned closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant