#1012717 git-buildpackage: git-buildpackage should declare a dependency on python 3.10

#1012717#5
Date:
2022-06-12 18:37:20 UTC
From:
To:
Dear Maintainer,

I was attempting to update some packages using git-buildpackage and had
the following stack trace


~/src/debian/geiser$ gbp import-orig --uscan
Traceback (most recent call last):
  File "/usr/bin/gbp", line 149, in <module>
    sys.exit(supercommand())
  File "/usr/bin/gbp", line 137, in supercommand
    module = import_command(cmd)
  File "/usr/bin/gbp", line 71, in import_command
    return __import__('gbp.scripts.%s' % modulename, fromlist='main', level=0)
  File "/usr/lib/python3/dist-packages/gbp/scripts/import_orig.py", line 26, in <module>
    from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
  File "/usr/lib/python3/dist-packages/gbp/deb/__init__.py", line 28, in <module>
    from gbp.deb.policy import DebianPkgPolicy                # noqa: F401
  File "/usr/lib/python3/dist-packages/gbp/deb/policy.py", line 27, in <module>
    from gbp.pkg.pkgpolicy import PkgPolicy
  File "/usr/lib/python3/dist-packages/gbp/pkg/__init__.py", line 20, in <module>
    from gbp.pkg.pkgpolicy import PkgPolicy             # noqa: F401
  File "/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py", line 28, in <module>
    class PkgPolicy(object):
  File "/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py", line 36, in PkgPolicy
    packagename_re: typing.Pattern[str] | None = None
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'


After looking the problem it up there's a line where it's trying to do a
union type between _GenericAlias and NoneType, but that's a feature that
was added in 3.10.
https://peps.python.org/pep-0604/

Some of us on testing still have 3.9 as the default because numba
doesn't work with 3.10. I think it's pretty reasonable to inidicate that
gpb 0.9.27 does requires 3.10.

Thank you,
Diane Trout

#1012717#10
Date:
2022-06-12 19:52:27 UTC
From:
To:
Hi,

I'm also happy to apply a patch that makes it compatible with python 3.9
again. The gain from the type annotations is pretty low atm.
 -- Guido

#1012717#15
Date:
2022-06-12 20:24:31 UTC
From:
To:

This looks like a good solution for 3.9 & 3.10 compatibility
it works on both 3.9 and 3.10 and expresses the same meaning.
https://docs.python.org/3/library/typing.html#typing.Optional

Diane

diff --git a/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py~
b/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py
index c5427ee..9016828 100644
--- a/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py~
+++ b/usr/lib/python3/dist-packages/gbp/pkg/pkgpolicy.py
@@ -34,8 +34,8 @@ class PkgPolicy(object):
                          r'%(?P<R>([^%]|\\%))+'
                          r'\)s')
-    packagename_re: typing.Pattern[str] | None = None
-    packagename_msg: str | None = None
-    upstreamversion_re: typing.Pattern[str] | None = None
-    upstreamversion_msg: str | None = None
+    packagename_re: typing.Optional[typing.Pattern[str]] = None
+    packagename_msg: typing.Optional[str] = None
+    upstreamversion_re: typing.Optional[typing.Pattern[str]] = None
+    upstreamversion_msg: typing.Optional[str] = None

     @classmethod

#1012717#22
Date:
2022-06-13 07:47:27 UTC
From:
To:
tag 1012717 pending
thanks

Date:   Mon Jun 13 09:41:59 2022 +0200
Author: Diane Trout <diane@ghic.org>
Commit ID: 09338d25d3da84fff9cbd0a17d87762744546122
Commit URL: https://git.sigxcpu.org/cgit/git-buildpackage//commit/?id=09338d25d3da84fff9cbd0a17d87762744546122
Patch URL: https://git.sigxcpu.org/cgit/git-buildpackage//patch/?id=09338d25d3da84fff9cbd0a17d87762744546122

    pkgpolicy: Use type annotations that also work for python 3.9

    Closes: #1012717

#1012717#27
Date:
2022-06-13 07:47:45 UTC
From:
To:
Hi Diane,

That works, thanks!
 -- Guido

#1012717#34
Date:
2022-07-04 15:33:01 UTC
From:
To:
Hi Guido!

Hope you're doing fine.  Have you got any plans for the next GBP PyPI
release yet?  I understand there're only two patches committed since
0.9.27 and I don't want to hurry you, just need to plan an immediate way
forward, because this bug breaks our automated workflow.  "Don't expect
anything until after Debconf at least" would be a perfectly fine answer,
I'd just rather not make a mess for no reason.

#1012717#39
Date:
2022-07-05 10:34:01 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
git-buildpackage, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1012717@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Guido Günther <agx@sigxcpu.org> (supplier of updated git-buildpackage package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 05 Jul 2022 11:50:33 +0200
Source: git-buildpackage
Architecture: source
Version: 0.9.28
Distribution: unstable
Urgency: medium
Maintainer: Guido Günther <agx@sigxcpu.org>
Changed-By: Guido Günther <agx@sigxcpu.org>
Closes: 1012717
Changes:
 git-buildpackage (0.9.28) unstable; urgency=medium
 .
   [ Diane Trout ]
   * [09338d2] pkgpolicy: Use type annotations that also work for python 3.9
     (Closes: #1012717)
 .
   [ Guido Günther ]
   * [666389b] export-orig: Allow for --pristine-tar-commit.
     No reason to restrict this to build-package
Checksums-Sha1:
 504dfdce4ae1df1fe0b2707d119ddff9dee5a1f6 2340 git-buildpackage_0.9.28.dsc
 1eff59178f6a204f1618ee9f61f8c657171838a0 3496084 git-buildpackage_0.9.28.tar.xz
 9ec514f708ad00b2799d7b39447f8c6790e88a85 13000 git-buildpackage_0.9.28_amd64.buildinfo
Checksums-Sha256:
 4302dde4bcd741b1832b49667104ec4612b8af2dbf0152882e9a268eee0b07da 2340 git-buildpackage_0.9.28.dsc
 903cb0bcd0ec1041cbb80bd77e8171ec3fa8b3efeed815221b9c5524990ec3dd 3496084 git-buildpackage_0.9.28.tar.xz
 c978433b0fd3e52e3ae4d0b6196dad923522733c2787658d40d3c7c9c23b5dfc 13000 git-buildpackage_0.9.28_amd64.buildinfo
Files:
 d70feb2352badbbd1e8a4f9fdcefaa80 2340 vcs optional git-buildpackage_0.9.28.dsc
 ca6a5c4df93e8a0de18bdc2839896e58 3496084 vcs optional git-buildpackage_0.9.28.tar.xz
 122e09a9a4164c8b13eeeff0a5b5cb0d 13000 vcs optional git-buildpackage_0.9.28_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEY/bM35YinQkoayrDJb+GUkr8weMFAmLEDtUACgkQJb+GUkr8
weONeBAAmaXgLohwc3fTQm1IWcSPfyqsITnAdGhgxESjx69tG+e79SXVX9jHjcqn
/nCZcrAmqLdCpQ2VjdRaW0+49CTiwZouyEW+D8eCMVDLhPpnu655PsE2snYJJ2SD
rk3HATitvTOhik6o4oBbmiPLL9VrtKj/iZsvGZ9ySNzNcUFWdsFiC7jhqB+wSE3r
huGnImlcFyf836FWR+Vm31cTbNxok1O1uCEeUKNp0elnKUAu5I5odMnZXLgkkUYr
W8UWOUDC57Rn64CXe1yEHzxid1/zJKKvDMsv/j98+DMqaV02G9A2M0nxfDNRh9r2
Q+DcEhKpHPA+by+y5WTYdLgRBsOoCNXp1Ece3+hy+87FKQqGY79lkQImF5OhGhBa
noFHePe9d5/kjQkOwQm2/BiCogS5OqKZjRssRU2xt36W+IdawXbLdt0i4ocBfqjI
xUFVdN/OEGqZDr2oIZbJfIX2PkVj0HaQGYT6b3mtlAneLEENebs9IxIH0F/Zqz/R
Cs/GpqGNPDctXajvwUjJzhdoQRrllAva/tjU62X6etRIoqJaI4XbumoSyvwWXvZx
ieHY/RaIDz2yaLaKHMayf1uXNcFjmozObrukGxKuY5H+Nr2oU1sKt4gCymSpkL1W
kQeeMN8l0yYNeLN5sdE1aHi2NgHG5+chqcsP8y10+a+fbXcqXkc=
=9Gqg
-----END PGP SIGNATURE-----