adafruit-circuitpython-gps 3.11.0__tar.gz → 3.11.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. adafruit_circuitpython_gps-3.11.2/.gitattributes +11 -0
  2. adafruit_circuitpython_gps-3.11.2/.pre-commit-config.yaml +21 -0
  3. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.readthedocs.yaml +3 -0
  4. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/PKG-INFO +6 -5
  5. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/README.rst +3 -3
  6. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_circuitpython_gps.egg-info/PKG-INFO +6 -5
  7. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_circuitpython_gps.egg-info/SOURCES.txt +2 -1
  8. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_gps.py +25 -44
  9. adafruit_circuitpython_gps-3.11.2/docs/api.rst +11 -0
  10. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/conf.py +2 -6
  11. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_datalogging.py +1 -0
  12. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_displayio_simpletest.py +1 -0
  13. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_echotest.py +1 -0
  14. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_satellitefix.py +1 -0
  15. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_simpletest.py +14 -21
  16. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/examples/gps_time_source.py +8 -11
  17. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/pyproject.toml +1 -1
  18. adafruit_circuitpython_gps-3.11.2/ruff.toml +108 -0
  19. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/tests/adafruit_gps_test.py +24 -36
  20. adafruit_circuitpython_gps-3.11.0/.pre-commit-config.yaml +0 -42
  21. adafruit_circuitpython_gps-3.11.0/.pylintrc +0 -399
  22. adafruit_circuitpython_gps-3.11.0/docs/api.rst +0 -5
  23. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.coveragerc +0 -0
  24. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
  25. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.github/workflows/build.yml +0 -0
  26. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.github/workflows/failure-help-text.yml +0 -0
  27. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.github/workflows/release_gh.yml +0 -0
  28. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.github/workflows/release_pypi.yml +0 -0
  29. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/.gitignore +0 -0
  30. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/CODE_OF_CONDUCT.md +0 -0
  31. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/LICENSE +0 -0
  32. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/LICENSES/CC-BY-4.0.txt +0 -0
  33. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/LICENSES/MIT.txt +0 -0
  34. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/LICENSES/Unlicense.txt +0 -0
  35. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/README.rst.license +0 -0
  36. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_circuitpython_gps.egg-info/dependency_links.txt +0 -0
  37. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_circuitpython_gps.egg-info/requires.txt +0 -0
  38. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/adafruit_circuitpython_gps.egg-info/top_level.txt +0 -0
  39. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/_static/favicon.ico +0 -0
  40. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/_static/favicon.ico.license +0 -0
  41. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/api.rst.license +0 -0
  42. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/details.rst +0 -0
  43. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/details.rst.license +0 -0
  44. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/examples.rst +0 -0
  45. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/examples.rst.license +0 -0
  46. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/index.rst +0 -0
  47. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/index.rst.license +0 -0
  48. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/docs/requirements.txt +0 -0
  49. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/optional_requirements.txt +0 -0
  50. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/requirements.txt +0 -0
  51. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/setup.cfg +0 -0
  52. {adafruit_circuitpython_gps-3.11.0 → adafruit_circuitpython_gps-3.11.2}/tests/__init__.py +0 -0
@@ -0,0 +1,11 @@
1
+ # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: Unlicense
4
+
5
+ .py text eol=lf
6
+ .rst text eol=lf
7
+ .txt text eol=lf
8
+ .yaml text eol=lf
9
+ .toml text eol=lf
10
+ .license text eol=lf
11
+ .md text eol=lf
@@ -0,0 +1,21 @@
1
+ # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: Unlicense
4
+
5
+ repos:
6
+ - repo: https://github.com/pre-commit/pre-commit-hooks
7
+ rev: v4.5.0
8
+ hooks:
9
+ - id: check-yaml
10
+ - id: end-of-file-fixer
11
+ - id: trailing-whitespace
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ rev: v0.3.4
14
+ hooks:
15
+ - id: ruff-format
16
+ - id: ruff
17
+ args: ["--fix"]
18
+ - repo: https://github.com/fsfe/reuse-tool
19
+ rev: v3.0.1
20
+ hooks:
21
+ - id: reuse
@@ -8,6 +8,9 @@
8
8
  # Required
9
9
  version: 2
10
10
 
11
+ sphinx:
12
+ configuration: docs/conf.py
13
+
11
14
  build:
12
15
  os: ubuntu-20.04
13
16
  tools:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: adafruit-circuitpython-gps
3
- Version: 3.11.0
3
+ Version: 3.11.2
4
4
  Summary: CircuitPython library for GPS modules.
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -25,6 +25,7 @@ Requires-Dist: covdefaults; extra == "optional"
25
25
  Requires-Dist: coverage; extra == "optional"
26
26
  Requires-Dist: freezegun; extra == "optional"
27
27
  Requires-Dist: pytest; extra == "optional"
28
+ Dynamic: license-file
28
29
 
29
30
  Introduction
30
31
  ============
@@ -41,9 +42,9 @@ Introduction
41
42
  :target: https://github.com/adafruit/Adafruit_CircuitPython_GPS/actions/
42
43
  :alt: Build Status
43
44
 
44
- .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
45
- :target: https://github.com/psf/black
46
- :alt: Code Style: Black
45
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
46
+ :target: https://github.com/astral-sh/ruff
47
+ :alt: Code Style: Ruff
47
48
 
48
49
  GPS parsing module. Can send commands to, and parse simple NMEA data sentences
49
50
  from serial and I2C GPS modules to read latitude, longitude, and more.
@@ -13,9 +13,9 @@ Introduction
13
13
  :target: https://github.com/adafruit/Adafruit_CircuitPython_GPS/actions/
14
14
  :alt: Build Status
15
15
 
16
- .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
17
- :target: https://github.com/psf/black
18
- :alt: Code Style: Black
16
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
17
+ :target: https://github.com/astral-sh/ruff
18
+ :alt: Code Style: Ruff
19
19
 
20
20
  GPS parsing module. Can send commands to, and parse simple NMEA data sentences
21
21
  from serial and I2C GPS modules to read latitude, longitude, and more.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: adafruit-circuitpython-gps
3
- Version: 3.11.0
3
+ Version: 3.11.2
4
4
  Summary: CircuitPython library for GPS modules.
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -25,6 +25,7 @@ Requires-Dist: covdefaults; extra == "optional"
25
25
  Requires-Dist: coverage; extra == "optional"
26
26
  Requires-Dist: freezegun; extra == "optional"
27
27
  Requires-Dist: pytest; extra == "optional"
28
+ Dynamic: license-file
28
29
 
29
30
  Introduction
30
31
  ============
@@ -41,9 +42,9 @@ Introduction
41
42
  :target: https://github.com/adafruit/Adafruit_CircuitPython_GPS/actions/
42
43
  :alt: Build Status
43
44
 
44
- .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
45
- :target: https://github.com/psf/black
46
- :alt: Code Style: Black
45
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
46
+ :target: https://github.com/astral-sh/ruff
47
+ :alt: Code Style: Ruff
47
48
 
48
49
  GPS parsing module. Can send commands to, and parse simple NMEA data sentences
49
50
  from serial and I2C GPS modules to read latitude, longitude, and more.
@@ -1,7 +1,7 @@
1
1
  .coveragerc
2
+ .gitattributes
2
3
  .gitignore
3
4
  .pre-commit-config.yaml
4
- .pylintrc
5
5
  .readthedocs.yaml
6
6
  CODE_OF_CONDUCT.md
7
7
  LICENSE
@@ -11,6 +11,7 @@ adafruit_gps.py
11
11
  optional_requirements.txt
12
12
  pyproject.toml
13
13
  requirements.txt
14
+ ruff.toml
14
15
  .github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md
15
16
  .github/workflows/build.yml
16
17
  .github/workflows/failure-help-text.yml
@@ -26,18 +26,21 @@ Implementation Notes
26
26
  https://github.com/adafruit/circuitpython/releases
27
27
 
28
28
  """
29
+
29
30
  import time
31
+
30
32
  from micropython import const
31
33
 
32
34
  try:
33
- from typing import Optional, Tuple, List
34
- from typing_extensions import Literal
35
+ from typing import List, Optional, Tuple
36
+
37
+ from busio import I2C, UART
35
38
  from circuitpython_typing import ReadableBuffer
36
- from busio import UART, I2C
39
+ from typing_extensions import Literal
37
40
  except ImportError:
38
41
  pass
39
42
 
40
- __version__ = "3.11.0"
43
+ __version__ = "3.11.2"
41
44
  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_GPS.git"
42
45
 
43
46
 
@@ -103,19 +106,19 @@ def _parse_degrees(nmea_data: str) -> int:
103
106
 
104
107
 
105
108
  def _parse_int(nmea_data: str) -> int:
106
- if nmea_data is None or nmea_data == "":
109
+ if nmea_data is None or not nmea_data:
107
110
  return None
108
111
  return int(nmea_data)
109
112
 
110
113
 
111
114
  def _parse_float(nmea_data: str) -> float:
112
- if nmea_data is None or nmea_data == "":
115
+ if nmea_data is None or not nmea_data:
113
116
  return None
114
117
  return float(nmea_data)
115
118
 
116
119
 
117
120
  def _parse_str(nmea_data: str) -> str:
118
- if nmea_data is None or nmea_data == "":
121
+ if nmea_data is None or not nmea_data:
119
122
  return None
120
123
  return str(nmea_data)
121
124
 
@@ -162,7 +165,6 @@ def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
162
165
  """Parse sentence data for the specified sentence type and
163
166
  return a list of parameters in the correct format, or return None.
164
167
  """
165
- # pylint: disable=too-many-branches
166
168
 
167
169
  if not _ST_MIN <= sentence_type <= _ST_MAX:
168
170
  # The sentence_type is unknown
@@ -239,14 +241,11 @@ def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
239
241
  return params
240
242
 
241
243
 
242
- # pylint: disable-msg=too-many-instance-attributes
243
244
  class GPS:
244
245
  """GPS parsing module. Can parse simple NMEA data sentences from serial
245
246
  GPS modules to read latitude, longitude, and more.
246
247
  """
247
248
 
248
- # lint warning about too many statements disabled
249
- # pylint: disable-msg=R0915
250
249
  def __init__(self, uart: UART, debug: bool = False) -> None:
251
250
  self._uart = uart
252
251
  # Initialize null starting values for GPS attributes.
@@ -362,7 +361,7 @@ class GPS:
362
361
  # GP - GPS
363
362
  # GQ - QZSS
364
363
  # GN - GNSS / More than one of the above
365
- if talker not in (b"GA", b"GB", b"GI", b"GL", b"GP", b"GQ", b"GN"):
364
+ if talker not in {b"GA", b"GB", b"GI", b"GL", b"GP", b"GQ", b"GN"}:
366
365
  # It's not a known GNSS source of data
367
366
  # Assume it's a valid packet anyway
368
367
  return True
@@ -397,7 +396,7 @@ class GPS:
397
396
  for char in command:
398
397
  checksum ^= char
399
398
  self.write(b"*")
400
- self.write(bytes("{:02x}".format(checksum).upper(), "ascii"))
399
+ self.write(bytes(f"{checksum:02x}".upper(), "ascii"))
401
400
  self.write(b"\r\n")
402
401
 
403
402
  @property
@@ -444,7 +443,6 @@ class GPS:
444
443
 
445
444
  def _read_sentence(self) -> Optional[str]:
446
445
  # Parse any NMEA sentence that is available.
447
- # pylint: disable=len-as-condition
448
446
  # This needs to be refactored when it can be tested.
449
447
 
450
448
  # Only continue if we have at least 11 bytes in the input buffer
@@ -508,9 +506,7 @@ class GPS:
508
506
  month = int(date[2:4])
509
507
  year = 2000 + int(date[4:6])
510
508
 
511
- self.timestamp_utc = time.struct_time(
512
- (year, month, day, hours, mins, secs, 0, 0, -1)
513
- )
509
+ self.timestamp_utc = time.struct_time((year, month, day, hours, mins, secs, 0, 0, -1))
514
510
 
515
511
  def _parse_vtg(self, data: List[str]) -> bool:
516
512
  # VTG - Course Over Ground and Ground Speed
@@ -547,15 +543,11 @@ class GPS:
547
543
 
548
544
  # Latitude
549
545
  self.latitude = _read_degrees(parsed_data, 0, "s")
550
- self.latitude_degrees, self.latitude_minutes = _read_deg_mins(
551
- data=data, index=0, neg="s"
552
- )
546
+ self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=0, neg="s")
553
547
 
554
548
  # Longitude
555
549
  self.longitude = _read_degrees(parsed_data, 2, "w")
556
- self.longitude_degrees, self.longitude_minutes = _read_deg_mins(
557
- data=data, index=2, neg="w"
558
- )
550
+ self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=2, neg="w")
559
551
 
560
552
  # UTC time of position
561
553
  self._update_timestamp_utc(parsed_data[4])
@@ -571,7 +563,7 @@ class GPS:
571
563
  def _parse_rmc(self, data: List[str]) -> bool:
572
564
  # RMC - Recommended Minimum Navigation Information
573
565
 
574
- if data is None or len(data) not in (12, 13):
566
+ if data is None or len(data) not in {12, 13}:
575
567
  return False # Unexpected number of params.
576
568
  parsed_data = _parse_data({12: _RMC, 13: _RMC_4_1}[len(data)], data)
577
569
  if parsed_data is None:
@@ -591,15 +583,11 @@ class GPS:
591
583
 
592
584
  # Latitude
593
585
  self.latitude = _read_degrees(parsed_data, 2, "s")
594
- self.latitude_degrees, self.latitude_minutes = _read_deg_mins(
595
- data=data, index=2, neg="s"
596
- )
586
+ self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=2, neg="s")
597
587
 
598
588
  # Longitude
599
589
  self.longitude = _read_degrees(parsed_data, 4, "w")
600
- self.longitude_degrees, self.longitude_minutes = _read_deg_mins(
601
- data=data, index=4, neg="w"
602
- )
590
+ self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=4, neg="w")
603
591
 
604
592
  # Speed over ground, knots
605
593
  self.speed_knots = parsed_data[6]
@@ -633,15 +621,11 @@ class GPS:
633
621
 
634
622
  # Latitude
635
623
  self.latitude = _read_degrees(parsed_data, 1, "s")
636
- self.longitude_degrees, self.longitude_minutes = _read_deg_mins(
637
- data=data, index=3, neg="w"
638
- )
624
+ self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=3, neg="w")
639
625
 
640
626
  # Longitude
641
627
  self.longitude = _read_degrees(parsed_data, 3, "w")
642
- self.latitude_degrees, self.latitude_minutes = _read_deg_mins(
643
- data=data, index=1, neg="s"
644
- )
628
+ self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=1, neg="s")
645
629
 
646
630
  # GPS quality indicator
647
631
  self.fix_quality = parsed_data[5]
@@ -668,7 +652,7 @@ class GPS:
668
652
  def _parse_gsa(self, talker: bytes, data: List[str]) -> bool:
669
653
  # GSA - GPS DOP and active satellites
670
654
 
671
- if data is None or len(data) not in (17, 18):
655
+ if data is None or len(data) not in {17, 18}:
672
656
  return False # Unexpected number of params.
673
657
  if len(data) == 17:
674
658
  data = _parse_data(_GSA, data)
@@ -689,7 +673,7 @@ class GPS:
689
673
  satlist = list(filter(None, data[2:-4]))
690
674
  self.sat_prns = []
691
675
  for sat in satlist:
692
- self.sat_prns.append("{}{}".format(talker, sat))
676
+ self.sat_prns.append(f"{talker}{sat}")
693
677
 
694
678
  # PDOP, dilution of precision
695
679
  self.pdop = _parse_float(data[14])
@@ -706,9 +690,8 @@ class GPS:
706
690
 
707
691
  def _parse_gsv(self, talker: bytes, data: List[str]) -> bool:
708
692
  # GSV - Satellites in view
709
- # pylint: disable=too-many-branches
710
693
 
711
- if data is None or len(data) not in (7, 11, 15, 19):
694
+ if data is None or len(data) not in {7, 11, 15, 19}:
712
695
  return False # Unexpected number of params.
713
696
  data = _parse_data(
714
697
  {7: _GSV7, 11: _GSV11, 15: _GSV15, 19: _GSV19}[len(data)],
@@ -734,7 +717,7 @@ class GPS:
734
717
  j = i * 4
735
718
  value = (
736
719
  # Satellite number
737
- "{}{}".format(talker, sat_tup[0 + j]),
720
+ f"{talker}{sat_tup[0 + j]}",
738
721
  # Elevation in degrees
739
722
  sat_tup[1 + j],
740
723
  # Azimuth in degrees
@@ -789,9 +772,7 @@ class GPS_GtopI2C(GPS):
789
772
  debug: bool = False,
790
773
  timeout: float = 5.0,
791
774
  ) -> None:
792
- from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel
793
- i2c_device,
794
- )
775
+ from adafruit_bus_device import i2c_device # noqa: PLC0415
795
776
 
796
777
  super().__init__(None, debug) # init the parent with no UART
797
778
  self._i2c = i2c_device.I2CDevice(i2c_bus, address)
@@ -0,0 +1,11 @@
1
+
2
+ .. If you created a package, create one automodule per module in the package.
3
+
4
+ .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
5
+ .. use this format as the module name: "adafruit_foo.foo"
6
+
7
+ API Reference
8
+ #############
9
+
10
+ .. automodule:: adafruit_gps
11
+ :members:
@@ -1,12 +1,10 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
4
2
  #
5
3
  # SPDX-License-Identifier: MIT
6
4
 
5
+ import datetime
7
6
  import os
8
7
  import sys
9
- import datetime
10
8
 
11
9
  sys.path.insert(0, os.path.abspath(".."))
12
10
 
@@ -40,9 +38,7 @@ project = "Adafruit GPS Library"
40
38
  creation_year = "2017"
41
39
  current_year = str(datetime.datetime.now().year)
42
40
  year_duration = (
43
- current_year
44
- if current_year == creation_year
45
- else creation_year + " - " + current_year
41
+ current_year if current_year == creation_year else creation_year + " - " + current_year
46
42
  )
47
43
  copyright = year_duration + " Tony DiCola, James Carr"
48
44
  author = "Tony DiCola, James Carr"
@@ -14,6 +14,7 @@ import sys
14
14
 
15
15
  import board
16
16
  import busio
17
+
17
18
  import adafruit_gps
18
19
 
19
20
  # Path to the file to log GPS data. By default this will be appended to
@@ -2,6 +2,7 @@
2
2
  # SPDX-License-Identifier: MIT
3
3
 
4
4
  import time
5
+
5
6
  import board
6
7
  from adafruit_display_text.label import Label
7
8
  from displayio import Group
@@ -5,6 +5,7 @@
5
5
  # Will print NMEA sentences received from the GPS, great for testing connection
6
6
  # Uses the GPS to send some commands, then reads directly from the GPS
7
7
  import time
8
+
8
9
  import board
9
10
  import busio
10
11
 
@@ -7,6 +7,7 @@
7
7
  # * GSV - Satellites in view
8
8
 
9
9
  import time
10
+
10
11
  import board
11
12
 
12
13
  import adafruit_gps
@@ -5,6 +5,7 @@
5
5
  # Will wait for a fix and print a message every second with the current location
6
6
  # and other details.
7
7
  import time
8
+
8
9
  import board
9
10
  import busio
10
11
 
@@ -74,7 +75,7 @@ while True:
74
75
  # Print out details about the fix like location, date, etc.
75
76
  print("=" * 40) # Print a separator line.
76
77
  print(
77
- "Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format(
78
+ "Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format( # noqa: UP032
78
79
  gps.timestamp_utc.tm_mon, # Grab parts of the time from the
79
80
  gps.timestamp_utc.tm_mday, # struct_time object that holds
80
81
  gps.timestamp_utc.tm_year, # the fix time. Note you might
@@ -83,32 +84,24 @@ while True:
83
84
  gps.timestamp_utc.tm_sec,
84
85
  )
85
86
  )
86
- print("Latitude: {0:.6f} degrees".format(gps.latitude))
87
- print("Longitude: {0:.6f} degrees".format(gps.longitude))
88
- print(
89
- "Precise Latitude: {} degs, {:2.4f} mins".format(
90
- gps.latitude_degrees, gps.latitude_minutes
91
- )
92
- )
93
- print(
94
- "Precise Longitude: {} degs, {:2.4f} mins".format(
95
- gps.longitude_degrees, gps.longitude_minutes
96
- )
97
- )
98
- print("Fix quality: {}".format(gps.fix_quality))
87
+ print(f"Latitude: {gps.latitude:.6f} degrees")
88
+ print(f"Longitude: {gps.longitude:.6f} degrees")
89
+ print(f"Precise Latitude: {gps.latitude_degrees} degs, {gps.latitude_minutes:2.4f} mins")
90
+ print(f"Precise Longitude: {gps.longitude_degrees} degs, {gps.longitude_minutes:2.4f} mins")
91
+ print(f"Fix quality: {gps.fix_quality}")
99
92
  # Some attributes beyond latitude, longitude and timestamp are optional
100
93
  # and might not be present. Check if they're None before trying to use!
101
94
  if gps.satellites is not None:
102
- print("# satellites: {}".format(gps.satellites))
95
+ print(f"# satellites: {gps.satellites}")
103
96
  if gps.altitude_m is not None:
104
- print("Altitude: {} meters".format(gps.altitude_m))
97
+ print(f"Altitude: {gps.altitude_m} meters")
105
98
  if gps.speed_knots is not None:
106
- print("Speed: {} knots".format(gps.speed_knots))
99
+ print(f"Speed: {gps.speed_knots} knots")
107
100
  if gps.speed_kmh is not None:
108
- print("Speed: {} km/h".format(gps.speed_kmh))
101
+ print(f"Speed: {gps.speed_kmh} km/h")
109
102
  if gps.track_angle_deg is not None:
110
- print("Track angle: {} degrees".format(gps.track_angle_deg))
103
+ print(f"Track angle: {gps.track_angle_deg} degrees")
111
104
  if gps.horizontal_dilution is not None:
112
- print("Horizontal dilution: {}".format(gps.horizontal_dilution))
105
+ print(f"Horizontal dilution: {gps.horizontal_dilution}")
113
106
  if gps.height_geoid is not None:
114
- print("Height geoid: {} meters".format(gps.height_geoid))
107
+ print(f"Height geoid: {gps.height_geoid} meters")
@@ -6,9 +6,11 @@
6
6
  # time while there is powersource (ie coin cell battery)
7
7
 
8
8
  import time
9
+
9
10
  import board
10
11
  import busio
11
12
  import rtc
13
+
12
14
  import adafruit_gps
13
15
 
14
16
  uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
@@ -26,14 +28,9 @@ the_rtc = rtc.RTC()
26
28
 
27
29
 
28
30
  def _format_datetime(datetime):
29
- return "{:02}/{:02}/{} {:02}:{:02}:{:02}".format(
30
- datetime.tm_mon,
31
- datetime.tm_mday,
32
- datetime.tm_year,
33
- datetime.tm_hour,
34
- datetime.tm_min,
35
- datetime.tm_sec,
36
- )
31
+ date_part = f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year}"
32
+ time_part = f"{datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
33
+ return f"{date_part} {time_part}"
37
34
 
38
35
 
39
36
  last_print = time.monotonic()
@@ -47,12 +44,12 @@ while True:
47
44
  print("No time data from GPS yet")
48
45
  continue
49
46
  # Time & date from GPS informations
50
- print("Fix timestamp: {}".format(_format_datetime(gps.timestamp_utc)))
47
+ print(f"Fix timestamp: {_format_datetime(gps.timestamp_utc)}")
51
48
 
52
49
  # Time & date from internal RTC
53
- print("RTC timestamp: {}".format(_format_datetime(the_rtc.datetime)))
50
+ print(f"RTC timestamp: {_format_datetime(the_rtc.datetime)}")
54
51
 
55
52
  # Time & date from time.localtime() function
56
53
  local_time = time.localtime()
57
54
 
58
- print("Local time: {}".format(_format_datetime(local_time)))
55
+ print(f"Local time: {_format_datetime(local_time)}")
@@ -12,7 +12,7 @@ requires = [
12
12
  [project]
13
13
  name = "adafruit-circuitpython-gps"
14
14
  description = "CircuitPython library for GPS modules."
15
- version = "3.11.0"
15
+ version = "3.11.2"
16
16
  readme = "README.rst"
17
17
  authors = [
18
18
  {name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
@@ -0,0 +1,108 @@
1
+ # SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ target-version = "py38"
6
+ line-length = 100
7
+
8
+ [lint]
9
+ preview = true
10
+ select = ["I", "PL", "UP"]
11
+
12
+ extend-select = [
13
+ "D419", # empty-docstring
14
+ "E501", # line-too-long
15
+ "W291", # trailing-whitespace
16
+ "PLC0414", # useless-import-alias
17
+ "PLC2401", # non-ascii-name
18
+ "PLC2801", # unnecessary-dunder-call
19
+ "PLC3002", # unnecessary-direct-lambda-call
20
+ "E999", # syntax-error
21
+ "PLE0101", # return-in-init
22
+ "F706", # return-outside-function
23
+ "F704", # yield-outside-function
24
+ "PLE0116", # continue-in-finally
25
+ "PLE0117", # nonlocal-without-binding
26
+ "PLE0241", # duplicate-bases
27
+ "PLE0302", # unexpected-special-method-signature
28
+ "PLE0604", # invalid-all-object
29
+ "PLE0605", # invalid-all-format
30
+ "PLE0643", # potential-index-error
31
+ "PLE0704", # misplaced-bare-raise
32
+ "PLE1141", # dict-iter-missing-items
33
+ "PLE1142", # await-outside-async
34
+ "PLE1205", # logging-too-many-args
35
+ "PLE1206", # logging-too-few-args
36
+ "PLE1307", # bad-string-format-type
37
+ "PLE1310", # bad-str-strip-call
38
+ "PLE1507", # invalid-envvar-value
39
+ "PLE2502", # bidirectional-unicode
40
+ "PLE2510", # invalid-character-backspace
41
+ "PLE2512", # invalid-character-sub
42
+ "PLE2513", # invalid-character-esc
43
+ "PLE2514", # invalid-character-nul
44
+ "PLE2515", # invalid-character-zero-width-space
45
+ "PLR0124", # comparison-with-itself
46
+ "PLR0202", # no-classmethod-decorator
47
+ "PLR0203", # no-staticmethod-decorator
48
+ "UP004", # useless-object-inheritance
49
+ "PLR0206", # property-with-parameters
50
+ "PLR0904", # too-many-public-methods
51
+ "PLR0911", # too-many-return-statements
52
+ "PLR0912", # too-many-branches
53
+ "PLR0913", # too-many-arguments
54
+ "PLR0914", # too-many-locals
55
+ "PLR0915", # too-many-statements
56
+ "PLR0916", # too-many-boolean-expressions
57
+ "PLR1702", # too-many-nested-blocks
58
+ "PLR1704", # redefined-argument-from-local
59
+ "PLR1711", # useless-return
60
+ "C416", # unnecessary-comprehension
61
+ "PLR1733", # unnecessary-dict-index-lookup
62
+ "PLR1736", # unnecessary-list-index-lookup
63
+
64
+ # ruff reports this rule is unstable
65
+ #"PLR6301", # no-self-use
66
+
67
+ "PLW0108", # unnecessary-lambda
68
+ "PLW0120", # useless-else-on-loop
69
+ "PLW0127", # self-assigning-variable
70
+ "PLW0129", # assert-on-string-literal
71
+ "B033", # duplicate-value
72
+ "PLW0131", # named-expr-without-context
73
+ "PLW0245", # super-without-brackets
74
+ "PLW0406", # import-self
75
+ "PLW0602", # global-variable-not-assigned
76
+ "PLW0603", # global-statement
77
+ "PLW0604", # global-at-module-level
78
+
79
+ # fails on the try: import typing used by libraries
80
+ #"F401", # unused-import
81
+
82
+ "F841", # unused-variable
83
+ "E722", # bare-except
84
+ "PLW0711", # binary-op-exception
85
+ "PLW1501", # bad-open-mode
86
+ "PLW1508", # invalid-envvar-default
87
+ "PLW1509", # subprocess-popen-preexec-fn
88
+ "PLW2101", # useless-with-lock
89
+ "PLW3301", # nested-min-max
90
+ ]
91
+
92
+ ignore = [
93
+ "PLR2004", # magic-value-comparison
94
+ "UP030", # format literals
95
+ "PLW1514", # unspecified-encoding
96
+ "PLR0913", # too-many-arguments
97
+ "PLR0915", # too-many-statements
98
+ "PLR0917", # too-many-positional-arguments
99
+ "PLR0904", # too-many-public-methods
100
+ "PLR0912", # too-many-branches
101
+ "PLR0916", # too-many-boolean-expressions
102
+ ]
103
+
104
+ [lint.per-file-ignores]
105
+ "tests/adafruit_gps_test.py" = ["PLC2701"]
106
+
107
+ [format]
108
+ line-ending = "lf"