add some type hints (#774)

* type stubs for common, parser_pyx

* Cleanup imports

* values are indeed floats

* common.pyi complete, added cpp stubs

* parser_pyx.pyi complete

* CANPacker completed

* Holding temp changes...

* remove *.pyi

* just remove skip-file

Co-authored-by: Jason Shuler <jshuler@gmail.com>
This commit is contained in:
Adeeb Shihadeh 2023-01-01 17:09:27 -08:00 committed by GitHub
parent dcab27ca50
commit 107b96abfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -1,3 +1,2 @@
# pylint: skip-file
from opendbc.can.packer_pyx import CANPacker
from opendbc.can.packer_pyx import CANPacker # pylint: disable=no-name-in-module, import-error
assert CANPacker

View File

@ -10,12 +10,12 @@ include_pattern = re.compile(r'CM_ "IMPORT (.*?)";\n')
generated_suffix = '_generated.dbc'
def read_dbc(src_dir, filename):
def read_dbc(src_dir: str, filename: str) -> str:
with open(os.path.join(src_dir, filename)) as file_in:
return file_in.read()
def create_dbc(src_dir, filename, output_path):
def create_dbc(src_dir: str, filename: str, output_path: str):
dbc_file_in = read_dbc(src_dir, filename)
includes = include_pattern.findall(dbc_file_in)
@ -39,7 +39,7 @@ def create_dbc(src_dir, filename, output_path):
dbc_file_out.write(core_dbc)
def create_all(output_path):
def create_all(output_path: str):
# clear out old DBCs
for f in glob.glob(f"{output_path}/*{generated_suffix}"):
os.remove(f)