66Attempt to detect the current platform.
77"""
88import re
9-
10- from adafruit_platformdetect .board import Board
11- from adafruit_platformdetect .chip import Chip
9+ from typing import Optional
10+ from .board import Board
11+ from .chip import Chip
1212
1313
1414# Various methods here may retain state in future, so tell pylint not to worry
1717class Detector :
1818 """Wrap various platform detection functions."""
1919
20- def __init__ (self ):
20+ def __init__ (self ) -> None :
2121 self .board = Board (self )
2222 self .chip = Chip (self )
2323
24- def get_cpuinfo_field (self , field ) :
24+ def get_cpuinfo_field (self , field : str ) -> Optional [ str ] :
2525 """
2626 Search /proc/cpuinfo for a field and return its value, if found,
2727 otherwise None.
@@ -37,7 +37,7 @@ def get_cpuinfo_field(self, field):
3737 return match .group (1 )
3838 return None
3939
40- def check_dt_compatible_value (self , value ) :
40+ def check_dt_compatible_value (self , value : str ) -> bool :
4141 """
4242 Search /proc/device-tree/compatible for a value and return True, if found,
4343 otherwise False.
@@ -49,7 +49,7 @@ def check_dt_compatible_value(self, value):
4949
5050 return False
5151
52- def get_armbian_release_field (self , field ) :
52+ def get_armbian_release_field (self , field : str ) -> Optional [ str ] :
5353 """
5454 Search /etc/armbian-release, if it exists, for a field and return its
5555 value, if found, otherwise None.
@@ -69,7 +69,7 @@ def get_armbian_release_field(self, field):
6969
7070 return field_value
7171
72- def get_device_model (self ):
72+ def get_device_model (self ) -> Optional [ str ] :
7373 """
7474 Search /proc/device-tree/model for the device model and return its value, if found,
7575 otherwise None.
@@ -81,7 +81,7 @@ def get_device_model(self):
8181 pass
8282 return None
8383
84- def get_device_compatible (self ):
84+ def get_device_compatible (self ) -> Optional [ str ] :
8585 """
8686 Search /proc/device-tree/compatible for the compatible chip name.
8787 """
@@ -94,7 +94,7 @@ def get_device_compatible(self):
9494 pass
9595 return None
9696
97- def check_board_asset_tag_value (self ):
97+ def check_board_asset_tag_value (self ) -> Optional [ str ] :
9898 """
9999 Search /sys/devices/virtual/dmi/id for the device model and return its value, if found,
100100 otherwise None.
@@ -108,7 +108,7 @@ def check_board_asset_tag_value(self):
108108 pass
109109 return None
110110
111- def check_board_name_value (self ):
111+ def check_board_name_value (self ) -> Optional [ str ] :
112112 """
113113 Search /sys/devices/virtual/dmi/id for the board name and return its value, if found,
114114 otherwise None. Debian/ubuntu based
0 commit comments