File: fix-semver-deprecation-warnings

package info (click to toggle)
mu-editor 1.2.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,492 kB
  • sloc: python: 33,326; makefile: 154; xml: 32; sh: 7
file content (37 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Description: Update semver calls to use non-deprecated functions
 semver.parse and semver.compare are deprecated and will be removed
 in semver 3
Author: Nick Morrott <nickm@debian.org>
Forwarded: not-needed
Last-Update: 2022-02-15
---
Index: mu-editor/mu/modes/microbit.py
===================================================================
--- mu-editor.orig/mu/modes/microbit.py
+++ mu-editor/mu/modes/microbit.py
@@ -250,14 +250,13 @@ class MicrobitMode(MicroPythonMode):
             # New style versions, so the correct information will be
             # in the "release" field.
             # Check the release is a correct semantic version.
-            semver.parse(version_info["release"])
-            board_version = version_info["release"]
+            board_version = semver.VersionInfo.parse(version_info['release'])
             logger.info("Board MicroPython: {}".format(board_version))
         else:
             # MicroPython was found, but not with an expected version string.
             # 0.0.1 indicates an old unknown version. This is just a valid
             # arbitrary flag for semver comparison
-            board_version = "0.0.1"
+            board_version = semver.VersionInfo.parse('0.0.1')
         return board_version
 
     def flash(self):
@@ -368,7 +367,7 @@ class MicrobitMode(MicroPythonMode):
             logger.info("Mu MicroPython: {}".format(uflash_version))
             # If there's an older version of MicroPython on the device,
             # update it with the one packaged with Mu.
-            if semver.compare(board_version, uflash_version) < 0:
+            if board_version.compare(uflash.MICROPYTHON_VERSION) < 0:
                 logger.info("Board MicroPython is older than Mu's MicroPython")
                 update_micropython = True
         except Exception: