Add basic pre-commit to handle eol space (#592)

This commit is contained in:
J. Nick Koston 2023-10-19 14:00:36 -10:00 committed by GitHub
parent 713dae18f1
commit 741308c93f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 27 deletions

View File

@ -24,12 +24,12 @@ jobs:
- "3.9" - "3.9"
- "3.10" - "3.10"
- "3.11" - "3.11"
- "3.12" - "3.12"
os: os:
- ubuntu-latest - ubuntu-latest
extension: extension:
- "skip_cython" - "skip_cython"
- "use_cython" - "use_cython"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
@ -90,7 +90,7 @@ jobs:
name: Run tests with pytest name: Run tests with pytest
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
- run: | - run: |
docker run \ docker run \
-v "$PWD":/aioesphomeapi \ -v "$PWD":/aioesphomeapi \
ghcr.io/esphome/aioesphomeapi-proto-builder:latest ghcr.io/esphome/aioesphomeapi-proto-builder:latest

View File

@ -14,7 +14,6 @@
"message": 1 "message": 1
} }
] ]
} }
] ]
} }

View File

@ -58,4 +58,4 @@ jobs:
- uses: pypa/gh-action-pypi-publish@release/v1 - uses: pypa/gh-action-pypi-publish@release/v1
with: with:
password: ${{ secrets.PYPI_TOKEN }} password: ${{ secrets.PYPI_TOKEN }}

9
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,9 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

View File

@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.

View File

@ -13,4 +13,3 @@ Before creating a release: Check the latest commit passes continuous integration
When the release button on the draft is clicked, GitHub Actions will publish the release to PyPi. When the release button on the draft is clicked, GitHub Actions will publish the release to PyPi.
After any push to the main branch, the "protoc-update" workflow is run which updates the generated python protobuf files. This is to ensure that if a contributor has a newer protoc version installed than the protobuf python package, we won't run into any issues. After any push to the main branch, the "protoc-update" workflow is run which updates the generated python protobuf files. This is to ensure that if a contributor has a newer protoc version installed than the protobuf python package, we won't run into any issues.

View File

@ -43,25 +43,25 @@ The sample code below will connect to the device and retrieve details.
import aioesphomeapi import aioesphomeapi
import asyncio import asyncio
async def main(): async def main():
"""Connect to an ESPHome device and get details.""" """Connect to an ESPHome device and get details."""
# Establish connection # Establish connection
api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
await api.connect(login=True) await api.connect(login=True)
# Get API version of the device's firmware # Get API version of the device's firmware
print(api.api_version) print(api.api_version)
# Show device details # Show device details
device_info = await api.device_info() device_info = await api.device_info()
print(device_info) print(device_info)
# List all entities of the device # List all entities of the device
entities = await api.list_entities_services() entities = await api.list_entities_services()
print(entities) print(entities)
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.run_until_complete(main()) loop.run_until_complete(main())
@ -71,20 +71,20 @@ Subscribe to state changes of an ESPHome device.
import aioesphomeapi import aioesphomeapi
import asyncio import asyncio
async def main(): async def main():
"""Connect to an ESPHome device and wait for state changes.""" """Connect to an ESPHome device and wait for state changes."""
cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword") cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
await cli.connect(login=True) await cli.connect(login=True)
def change_callback(state): def change_callback(state):
"""Print the state changes of the device..""" """Print the state changes of the device.."""
print(state) print(state)
# Subscribe to the state changes # Subscribe to the state changes
await cli.subscribe_states(change_callback) await cli.subscribe_states(change_callback)
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
try: try:
asyncio.ensure_future(main()) asyncio.ensure_future(main())

View File

@ -25,4 +25,4 @@ cdef class APIFrameHelper:
cdef _add_to_buffer(self, bytes data) cdef _add_to_buffer(self, bytes data)
@cython.locals(end_of_frame_pos=cython.uint) @cython.locals(end_of_frame_pos=cython.uint)
cdef _remove_from_buffer(self) cdef _remove_from_buffer(self)

View File

@ -19,10 +19,10 @@ cdef class APINoiseFrameHelper(APIFrameHelper):
@cython.locals( @cython.locals(
header=bytes, header=bytes,
preamble=cython.uint, preamble=cython.uint,
msg_size_high=cython.uint, msg_size_high=cython.uint,
msg_size_low=cython.uint, msg_size_low=cython.uint,
) )
cpdef data_received(self, bytes data) cpdef data_received(self, bytes data)
@cython.locals( @cython.locals(

View File

@ -21,8 +21,8 @@ cdef class APIPlaintextFrameHelper(APIFrameHelper):
add_length=bytes, add_length=bytes,
end_of_frame_pos=cython.uint, end_of_frame_pos=cython.uint,
length_int=cython.uint, length_int=cython.uint,
preamble=cython.uint, preamble=cython.uint,
length_high=cython.uint, length_high=cython.uint,
maybe_msg_type=cython.uint maybe_msg_type=cython.uint
) )
cpdef data_received(self, bytes data) cpdef data_received(self, bytes data)

View File

@ -88,4 +88,4 @@ cdef class APIConnection:
cpdef add_message_callback(self, object on_message, tuple msg_types) cpdef add_message_callback(self, object on_message, tuple msg_types)
@cython.locals(handlers=set) @cython.locals(handlers=set)
cpdef _remove_message_callback(self, object on_message, tuple msg_types) cpdef _remove_message_callback(self, object on_message, tuple msg_types)

View File

@ -32,4 +32,3 @@ disable = [
[build-system] [build-system]
requires = ['setuptools>=65.4.1', 'wheel', 'Cython>=3.0.2'] requires = ['setuptools>=65.4.1', 'wheel', 'Cython>=3.0.2']