Skip to content

Commit

Permalink
Use mypyc to compile modules (ruundii#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Sep 10, 2023
1 parent 391044c commit 8e44095
Show file tree
Hide file tree
Showing 27 changed files with 677 additions and 322 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on: [pull_request, push]

jobs:
mypy:
name: Mypy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install libgirepository
run: sudo apt install -y libgirepository1.0-dev
- name: Install dependencies
uses: py-actions/py-dependency-install@v2
with:
path: requirements.txt
- name: Run mypy
run: mypy
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
/commands
.idea
.idea
*.so
__pycache__/
build/
install/on_rpi/bluez/
devices_config.json
*~
25 changes: 25 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[mypy]
files = a1314_message_filter.py, adapter.py, agent.py, bluetooth_devices.py, compatibility_device.py, hid_devices.py, hid_message_filter.py, mouse_message_filter.py
check_untyped_defs = True
follow_imports_for_stubs = True
disallow_any_decorated = True
disallow_any_explicit = True
disallow_any_expr = True
disallow_any_generics = True
disallow_any_unimported = True
disallow_incomplete_defs = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
disallow_untyped_defs = True
implicit_reexport = False
mypy_path = stubs/
no_implicit_optional = True
show_error_codes = True
strict_equality = True
warn_incomplete_stub = True
warn_no_return = True
warn_redundant_casts = True
warn_return_any = True
warn_unreachable = True
warn_unused_ignores = True
12 changes: 7 additions & 5 deletions a1314_message_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) 2020 ruundii. All rights reserved.

from typing import Optional

from hid_message_filter import HIDMessageFilter

Expand Down Expand Up @@ -37,14 +38,15 @@ class A1314MessageFilter(HIDMessageFilter):
#LeftControl: 0 | LeftShift: 0 | LeftAlt: 0 | Left GUI: 0 | RightControl: 0 | RightShift: 0 | RightAlt: 0 | Right GUI: 0 | # |Keyboard ['00', '00', '00', '00', '00', '00']


def __init__(self):
def __init__(self) -> None:
self.is_fn_pressed = False
self.is_eject_pressed = False
self.last_regular_report = bytearray(b'\x01\x00\x00\x00\x00\x00\x00\x00\x00')

def filter_message_to_host(self, msg):
if len(msg)<1:
def filter_message_to_host(self, msg: bytes) -> Optional[bytes]:
if len(msg) < 1:
return None

result_report = bytearray(msg)
if msg[0] == 0x11:
result_report = self.last_regular_report
Expand Down Expand Up @@ -117,5 +119,5 @@ def filter_message_to_host(self, msg):
self.last_regular_report = result_report
return b'\xa1'+bytes(result_report)

def filter_message_from_host(self, msg):
return msg[1:]
def filter_message_from_host(self, msg: bytes) -> bytes:
return msg[1:]
Loading

0 comments on commit 8e44095

Please sign in to comment.