File: fix-semver-deprecation-warnings

package info (click to toggle)
mu-editor 1.0.3%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,440 kB
  • sloc: python: 16,321; makefile: 129; xml: 29; sh: 7
file content (38 lines) | stat: -rw-r--r-- 1,959 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
38
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
---
--- a/mu/modes/microbit.py
+++ b/mu/modes/microbit.py
@@ -338,24 +338,22 @@
                     # in the "release" field.
                     try:
                         # 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'])
                     except ValueError:
                         # If it's an invalid semver, set to unknown version to
                         # force flash.
-                        board_version = '0.0.1'
+                        board_version = semver.VersionInfo.parse('0.0.1')
                 else:
                     # 0.0.1 indicates an old unknown version. This is just a
                     # valid arbitrary flag for semver comparison a couple of
                     # lines below.
-                    board_version = '0.0.1'
+                    board_version = semver.VersionInfo.parse('0.0.1')
                 logger.info('Board MicroPython: {}'.format(board_version))
                 logger.info(
                     'Mu MicroPython: {}'.format(uflash.MICROPYTHON_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.MICROPYTHON_VERSION) < 0:
+                if board_version.compare(uflash.MICROPYTHON_VERSION) < 0:
                     force_flash = True
             except Exception:
                 # Could not get version of MicroPython. This means either the