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 model for GET /v1/sensors requests #7

Merged
merged 18 commits into from
Nov 4, 2022
Merged

Add model for GET /v1/sensors requests #7

merged 18 commits into from
Nov 4, 2022

Conversation

bachya
Copy link
Owner

@bachya bachya commented Nov 3, 2022

Describe what the PR does:

SSIA

Note the use of Optional here instead of the more modern | operator. This is because of Pydantic on pre-Python 3.10: pydantic/pydantic#3300 (comment)

Hi everyone
You need to understand that int | str is not valid at runtime for python < 3.10 as type doesn't implement __or__.
It is valid at interpretation time by adding from __future__ import annotations but pydantic can't do magic and change how python works at runtime.
I opened a while ago pydantic/pydantic#2609, which works for python < 3.10 by using https://github.com/PrettyWood/future-typing, which changes at interpretation time int | str into Union[int, str] for example. But I don't think it's worth merging as moving to python 3.10 is safer
Hope it clarifies things

Since the primary purpose of this library is to support Home Assistant and HASS currently supports Python 3.9, we also need to. Once Python 3.12 is released, we can upgrade the syntax.

Does this fix a specific issue?

N/A

Checklist:

  • Confirm that one or more new tests are written for the new functionality.
  • Run tests and ensure everything passes (with 100% test coverage).
  • Update README.md with any new documentation.
  • Add yourself to AUTHORS.md.

@bachya bachya added the enhancement Enhancement of the code, not introducing new features. label Nov 3, 2022
@bachya bachya self-assigned this Nov 3, 2022
@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Merging #7 (7942d89) into dev (d26ce87) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               dev        #7   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         4    +2     
  Lines           31        99   +68     
=========================================
+ Hits            31        99   +68     
Impacted Files Coverage Δ
aiopurpleair/model/keys.py 100.00% <100.00%> (ø)
aiopurpleair/model/sensors.py 100.00% <100.00%> (ø)
aiopurpleair/model/validator.py 100.00% <100.00%> (ø)
aiopurpleair/util/dt.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@codeclimate
Copy link

codeclimate bot commented Nov 4, 2022

Code Climate has analyzed commit 7942d89 and detected 0 issues on this pull request.

View more on Code Climate.

@bachya bachya merged commit 5f1ad25 into dev Nov 4, 2022
@bachya bachya deleted the get-sensors-request branch November 4, 2022 00:07
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant