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

Correct documentation and type hints where functions may return None #151

Conversation

elliot-100
Copy link
Collaborator

@elliot-100 elliot-100 commented Sep 6, 2024

This PR makes several changes to type hints and docstrings. No run-time checking is done and there should be zero runtime impact.

  • Modernises existing Optional[Type] pattern hints to Python >= 3.10 Type | None pattern
  • Refactors type hints, by extracting a very simple JSONDict type alias to be used for dicts to be passed to/from JSON. It's equivalent to Dict[str, Any].

Together these mean that e.g. Optional[list[Dict[str, Any]]] can be written more simply, as list[JSONDict] | None.

  • Adds list[JSONDict] | None hint to relevant Spond, SpondClub attributes. Also adds relevant JSONDict hints to test fixtures and parameters.

NB: This does not add JSONDict hints to returns from Spond.send_message() or Spond.update_event() as these need a bit more thought - both seem to have oddities in what they currently return.

@elliot-100 elliot-100 merged commit 2fd23f1 into Olen:main Sep 14, 2024
5 checks passed
@elliot-100 elliot-100 deleted the 147-correct-documentation-and-type-hints-where-functions-may-return-none branch September 14, 2024 09:12
@elliot-100 elliot-100 added bug Something isn't working documentation Improvements or additions to documentation labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant