Skip to content

Commit

Permalink
Add basic pre-commit to handle eol space (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 20, 2023
1 parent 713dae1 commit 741308c
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.12"
os:
- ubuntu-latest
- ubuntu-latest
extension:
- "skip_cython"
- "use_cython"
- "use_cython"
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
name: Run tests with pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- run: |
- run: |
docker run \
-v "$PWD":/aioesphomeapi \
ghcr.io/esphome/aioesphomeapi-proto-builder:latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/matchers/pytest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"message": 1
}
]
}
}
]
}

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
password: ${{ secrets.PYPI_TOKEN }}
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
SOFTWARE.
SOFTWARE.
1 change: 0 additions & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

20 changes: 10 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ The sample code below will connect to the device and retrieve details.
import aioesphomeapi
import asyncio
async def main():
"""Connect to an ESPHome device and get details."""
# Establish connection
# Establish connection
api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
await api.connect(login=True)
# Get API version of the device's firmware
print(api.api_version)
# Show device details
device_info = await api.device_info()
print(device_info)
# List all entities of the device
entities = await api.list_entities_services()
print(entities)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Expand All @@ -71,20 +71,20 @@ Subscribe to state changes of an ESPHome device.
import aioesphomeapi
import asyncio
async def main():
"""Connect to an ESPHome device and wait for state changes."""
cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
await cli.connect(login=True)
def change_callback(state):
"""Print the state changes of the device.."""
print(state)
# Subscribe to the state changes
await cli.subscribe_states(change_callback)
loop = asyncio.get_event_loop()
try:
asyncio.ensure_future(main())
Expand Down
2 changes: 1 addition & 1 deletion aioesphomeapi/_frame_helper/base.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ cdef class APIFrameHelper:
cdef _add_to_buffer(self, bytes data)

@cython.locals(end_of_frame_pos=cython.uint)
cdef _remove_from_buffer(self)
cdef _remove_from_buffer(self)
6 changes: 3 additions & 3 deletions aioesphomeapi/_frame_helper/noise.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ cdef class APINoiseFrameHelper(APIFrameHelper):

@cython.locals(
header=bytes,
preamble=cython.uint,
msg_size_high=cython.uint,
preamble=cython.uint,
msg_size_high=cython.uint,
msg_size_low=cython.uint,
)
)
cpdef data_received(self, bytes data)

@cython.locals(
Expand Down
4 changes: 2 additions & 2 deletions aioesphomeapi/_frame_helper/plain_text.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ cdef class APIPlaintextFrameHelper(APIFrameHelper):
add_length=bytes,
end_of_frame_pos=cython.uint,
length_int=cython.uint,
preamble=cython.uint,
length_high=cython.uint,
preamble=cython.uint,
length_high=cython.uint,
maybe_msg_type=cython.uint
)
cpdef data_received(self, bytes data)
2 changes: 1 addition & 1 deletion aioesphomeapi/connection.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ cdef class APIConnection:
cpdef add_message_callback(self, object on_message, tuple msg_types)

@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)
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ disable = [

[build-system]
requires = ['setuptools>=65.4.1', 'wheel', 'Cython>=3.0.2']

0 comments on commit 741308c

Please sign in to comment.