3030import socket
3131
3232from math import pi , cos , acos , sin , atan2
33- import serial
33+ import gettext
34+ import serial # type: ignore
3435
3536from .dplatform import Platform
3637
3940from .aprs_icons import APRSicons
4041from .dratsexception import DPRSException
4142
42- # This makes pylance happy with out overriding settings
43- # from the invoker of the class
44- if not '_' in locals ():
45- import gettext
46- _ = gettext .gettext
43+ _ = gettext .gettext
4744
4845TEST = "$GPGGA,180718.02,4531.3740,N,12255.4599,W,1,07,1.4," \
4946 "50.6,M,-21.4,M,,*63 KE7JSS ,440.350+ PL127.3"
@@ -213,7 +210,7 @@ def calc(buf):
213210 for _char in buf :
214211 char = ord (_char )
215212 for _indx in range (0 , 8 ):
216- xorflag = ((( icomcrc ^ char ) & 0x01 ) == 0x01 )
213+ xorflag = ((icomcrc ^ char ) & 0x01 ) == 0x01
217214 icomcrc = (icomcrc >> 1 ) & 0x7fff
218215 if xorflag :
219216 icomcrc ^= 0x8408
@@ -707,14 +704,14 @@ def to_aprs(self, dest="APRATS",
707704 '''
708705 To APRS.
709706
710- :param dest: Destination, default "APRSATS "
707+ :param dest: Destination, default "APRATS "
711708 :param dest: str
712709 :param code: APRS code, default APRS_CAR_CODE
713710 :type code: str
714711 :returns: a GPS-A (APRS-compliant) string
715712 :rtype: str
716713 '''
717- symtab = code [0 ]
714+ symbol_table = code [0 ]
718715 symbol = code [1 ]
719716 stamp = time .strftime ("%H%M%S" , time .gmtime ())
720717
@@ -726,25 +723,25 @@ def to_aprs(self, dest="APRATS",
726723 sta_str = "%s>%s,DSTAR*:/%sh" % (sta , dest , stamp )
727724
728725 if self .latitude > 0 :
729- northsouth = "N"
726+ north_south = "N"
730727 lat_m = 1
731728 else :
732- northsouth = "S"
729+ north_south = "S"
733730 lat_m = - 1
734731
735732 if self .longitude > 0 :
736- eastwest = "E"
733+ east_west = "E"
737734 lon_m = 1
738735 else :
739- eastwest = "W"
736+ east_west = "W"
740737 lon_m = - 1
741738
742739 sta_str += "%07.2f%s%s%08.2f%s%s" % \
743740 (deg2nmea (self .latitude * lat_m ),
744- northsouth ,
745- symtab ,
741+ north_south ,
742+ symbol_table ,
746743 deg2nmea (self .longitude * lon_m ),
747- eastwest ,
744+ east_west ,
748745 symbol )
749746 if self .speed and self .direction :
750747 sta_str += "%03.0f/%03.0f" % \
@@ -891,7 +888,7 @@ def __init__(self, sentence, station=None):
891888 else :
892889 self .logger .info ("Unsupported GPS sentence type: %s" , sentence )
893890
894- def _test_checksum (self , string , csum ):
891+ def _test_checksum (self , string , checksum ):
895892 try :
896893 idx = string .index ("*" )
897894 except ValueError :
@@ -901,14 +898,14 @@ def _test_checksum(self, string, csum):
901898
902899 segment = string [1 :idx ]
903900
904- csum = csum .upper ()
905- calc_csum = nmea_checksum (segment ).upper ()
901+ checksum = checksum .upper ()
902+ calc_checksum = nmea_checksum (segment ).upper ()
906903
907- if csum != calc_csum :
904+ if checksum != calc_checksum :
908905 self .logger .info ("_test_checksum: Failed checksum: %s != %s" ,
909- csum , calc_csum )
906+ checksum , calc_checksum )
910907
911- return csum == calc_csum
908+ return checksum == calc_checksum
912909
913910 def _parse_gpgga (self , string ):
914911 elements = string .split ("," , 14 )
@@ -934,7 +931,7 @@ def _parse_gpgga(self, string):
934931 if not match :
935932 raise GpsGppgaChecksumError ("No checksum (%s)" % elements [14 ])
936933
937- csum = match .group (2 )
934+ checksum = match .group (2 )
938935 if "," in match .group (3 ):
939936 sta , com = match .group (3 ).split ("," , 1 )
940937 if not sta .strip ().startswith ("$" ):
@@ -945,7 +942,7 @@ def _parse_gpgga(self, string):
945942 if len (self .comment ) >= 7 and "*" in self .comment [- 3 :- 1 ]:
946943 self ._parse_dprs_comment ()
947944
948- self .valid = self ._test_checksum (string , csum )
945+ self .valid = self ._test_checksum (string , checksum )
949946
950947 def _parse_gprmc (self , string ):
951948 if "\r \n " in string :
@@ -984,7 +981,7 @@ def _parse_gprmc(self, string):
984981 self .logger .info ("_parse_gprmc: Invalid end: %s" , elements [end ])
985982 return
986983
987- csum = match .group (1 )
984+ checksum = match .group (1 )
988985 if "," in station :
989986 sta , com = station .split ("," , 1 )
990987 self .station = utils .filter_to_ascii (sta .strip ())
@@ -1000,7 +997,7 @@ def _parse_gprmc(self, string):
1000997 elements [2 ])
1001998 else :
1002999 self .logger .info ("_parse_gprmc: GPRMC is valid" )
1003- self .valid = self ._test_checksum (string , csum )
1000+ self .valid = self ._test_checksum (string , checksum )
10041001
10051002 def _from_nmea_gpgga (self , string ):
10061003 string = string .replace ('\r ' , ' ' )
@@ -1378,7 +1375,7 @@ def connect(self):
13781375 :rtype: bool
13791376 '''
13801377 try :
1381- _ , host , port = self .port .split (":" , 3 )
1378+ _proto , host , port = self .port .split (":" , 3 )
13821379 port = int (port )
13831380 except ValueError as err :
13841381 self .logger .info ("connect: Unable to parse %s (%s)" ,
0 commit comments