[PATCH 1 of 5] ci: pin pytype to 2022.03.29

3 views
Skip to first unread message

Matt Harbison

unread,
Oct 5, 2022, 9:15:28 PM10/5/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664984712 14400
# Wed Oct 05 11:45:12 2022 -0400
# Branch stable
# Node ID acfdfaf48d6fbb9bdcd8a0c922dfab0064c0b0b0
# Parent 8ef0493ff30adc38cd0dfd3e1a8d5cb5b2366af0
# EXP-Topic pin-pip
ci: pin pytype to 2022.03.29

Pytype depends on libcst, and the current version requires the Rust compiler, so
pytype wasn't running at all. Since new pytype releases randomly add false
positives or hangs, it's better to be explicit about the version anyway (and
this is the version and dependency pinned by Mercurial's pytype test).

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -89,7 +89,7 @@
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci
- - pip3 install --user --upgrade pytype
+ - pip3 install --user --upgrade libcst==0.3.20 pytype==2022.03.29
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update stable
- hg -R /ci/repos/mercurial summary
@@ -102,7 +102,7 @@
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci
- - pip3 install --user --upgrade pytype
+ - pip3 install --user --upgrade libcst==0.3.20 pytype==2022.03.29
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update default
- hg -R /ci/repos/mercurial summary
diff --git a/contrib/generate_gitlab_ci_yml.py b/contrib/generate_gitlab_ci_yml.py
--- a/contrib/generate_gitlab_ci_yml.py
+++ b/contrib/generate_gitlab_ci_yml.py
@@ -94,7 +94,9 @@
'image': docker_image_name(hgver, prebuilt_images),
'script': [
*gen_install_apt_dependencies(),
- f'pip3 install --user --upgrade pytype',
+ # Newer versions of libcst require rustc, so the docker images
+ # need to be updated to use a newer version of it.
+ 'pip3 install --user --upgrade libcst==0.3.20 pytype==2022.03.29',
*gen_update_to_mercurial_rev(hgver),
thg_make_command('local'),
# The following is a workaround for pytype's lack of support for

Matt Harbison

unread,
Oct 5, 2022, 9:15:29 PM10/5/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664987505 14400
# Wed Oct 05 12:31:45 2022 -0400
# Branch stable
# Node ID 83947b5524b64e0e87ccdc00cf8e92062fc3d1c6
# Parent acfdfaf48d6fbb9bdcd8a0c922dfab0064c0b0b0
# EXP-Topic pin-pip
pytype: disable a few more warnings about Windows specific modules being missing

diff --git a/tortoisehg/util/cachethg.py b/tortoisehg/util/cachethg.py
--- a/tortoisehg/util/cachethg.py
+++ b/tortoisehg/util/cachethg.py
@@ -31,9 +31,12 @@

try:
from mercurial.windows import winreg
+
+ # pytype: disable=module-attr
HKEY_CURRENT_USER = winreg.HKEY_CURRENT_USER
OpenKey = winreg.OpenKey
QueryValueEx = winreg.QueryValueEx
+ # pytype: enable=module-attr

from win32api import GetTickCount # pytype: disable=import-error
CACHE_TIMEOUT = 5000
diff --git a/tortoisehg/util/debugthg.py b/tortoisehg/util/debugthg.py
--- a/tortoisehg/util/debugthg.py
+++ b/tortoisehg/util/debugthg.py
@@ -11,6 +11,7 @@
try:
from mercurial.windows import winreg
try:
+ # pytype: disable=module-attr
hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r"Software\TortoiseHg", 0,
winreg.KEY_ALL_ACCESS)
@@ -18,6 +19,8 @@
if val in ('1', 'True'):
debugging += 'O'
val = winreg.QueryValueEx(hkey, 'ContextMenuDebug')[0]
+ # pytype: enable=module-attr
+
if val in ('1', 'True'):
debugging += 'M'
if debugging:
diff --git a/tortoisehg/util/gpg.py b/tortoisehg/util/gpg.py
--- a/tortoisehg/util/gpg.py
+++ b/tortoisehg/util/gpg.py
@@ -25,8 +25,10 @@
path = []
for key in (r"Software\GNU\GnuPG", r"Software\Wow6432Node\GNU\GnuPG"):
try:
+ # pytype: disable=module-attr
hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key)
pfx = winreg.QueryValueEx(hkey, 'Install Directory')[0]
+ # pytype: enable=module-attr
for dirPath, dirNames, fileNames in os.walk(pfx):
for f in fileNames:
if f == 'gpg.exe':

Matt Harbison

unread,
Oct 5, 2022, 9:15:30 PM10/5/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664990083 14400
# Wed Oct 05 13:14:43 2022 -0400
# Branch stable
# Node ID febba1c0feb4552e379409430a80ae5923c9939f
# Parent 83947b5524b64e0e87ccdc00cf8e92062fc3d1c6
# EXP-Topic pin-pip
pytype: disable a few bogus bad-return-type warnings

No idea what's going on here, but pytype thinks these are all actually returning
`Optional[Union[int, str]]` instead of how they are annotated.

diff --git a/tortoisehg/hgqt/cmdcore.py b/tortoisehg/hgqt/cmdcore.py
--- a/tortoisehg/hgqt/cmdcore.py
+++ b/tortoisehg/hgqt/cmdcore.py
@@ -77,23 +77,23 @@
@property
def topic(self):
# type: () -> pycompat.unicode
- return self[0]
+ return self[0] # pytype: disable=bad-return-type
@property
def pos(self):
# type: () -> Optional[int]
- return self[1]
+ return self[1] # pytype: disable=bad-return-type
@property
def item(self):
# type: () -> pycompat.unicode
- return self[2]
+ return self[2] # pytype: disable=bad-return-type
@property
def unit(self):
# type: () -> pycompat.unicode
- return self[3]
+ return self[3] # pytype: disable=bad-return-type
@property
def total(self):
# type: () -> Optional[int]
- return self[4]
+ return self[4] # pytype: disable=bad-return-type

def __repr__(self):
names = ('topic', 'pos', 'item', 'unit', 'total')

Matt Harbison

unread,
Oct 5, 2022, 9:15:31 PM10/5/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664994412 14400
# Wed Oct 05 14:26:52 2022 -0400
# Branch stable
# Node ID 074807f73390697f7be3e4b8c649891136cd983d
# Parent febba1c0feb4552e379409430a80ae5923c9939f
# EXP-Topic pin-pip
pytype: change an annotation from Set -> weakref.WeakSet

Both pytype and PyCharm complained about the previous annotation.

diff --git a/tortoisehg/hgqt/shortcutregistry.py b/tortoisehg/hgqt/shortcutregistry.py
--- a/tortoisehg/hgqt/shortcutregistry.py
+++ b/tortoisehg/hgqt/shortcutregistry.py
@@ -344,7 +344,7 @@
# C++ object is deleted. Since QAction will be instantiated per
# context (e.g. window), more than one instances may be registered
# to the same slot.
- self._actionsMap = collections.defaultdict(weakref.WeakSet) # type: Dict[Text, Set[QAction]]
+ self._actionsMap = collections.defaultdict(weakref.WeakSet) # type: Dict[Text, weakref.WeakSet[QAction]]

def applyChangesToActions(self):
"""Applies changes to registered QAction instances"""

Matt Harbison

unread,
Oct 5, 2022, 9:15:31 PM10/5/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664999581 14400
# Wed Oct 05 15:53:01 2022 -0400
# Branch stable
# Node ID fa4865f073cddc8c56549ba4b113fad283ebb470
# Parent 074807f73390697f7be3e4b8c649891136cd983d
# EXP-Topic pin-pip
pytype: disable a bogus attribute-error warning on pygments lexer

For some reason, pytype thinks the lexer type can be `pygments.lexer.LexerMeta`
or `None` instead of `pygments.lexer.Lexer`.

diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py
+++ b/tortoisehg/hgqt/commit.py
@@ -722,7 +722,11 @@
try:
contents = pycompat.unicode(contents)
lexer = guess_lexer_for_filename(wfile, contents)
+ assert lexer is not None # help pytype
+
+ # pytype: disable=attribute-error
for tokentype, value in lexer.get_tokens(contents):
+ # pytype: enable=attribute-error
if tokentype in Token.Name and len(value) > 4:
tokens.add(value)
except (ClassNotFound, TypeError):

Matt Harbison

unread,
Oct 5, 2022, 9:17:07 PM10/5/22
to TortoiseHg Developers
On Wednesday, October 5, 2022 at 9:15:28 PM UTC-4 Matt Harbison wrote:
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1664984712 14400
# Wed Oct 05 11:45:12 2022 -0400
# Branch stable
# Node ID acfdfaf48d6fbb9bdcd8a0c922dfab0064c0b0b0
# Parent 8ef0493ff30adc38cd0dfd3e1a8d5cb5b2366af0
# EXP-Topic pin-pip
ci: pin pytype to 2022.03.29

Also on the server in the pin-pip topic.
 

Yuya Nishihara

unread,
Oct 6, 2022, 12:36:18 AM10/6/22
to Matt Harbison, thg...@googlegroups.com
On Wed, 05 Oct 2022 21:15:25 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1664984712 14400
> # Wed Oct 05 11:45:12 2022 -0400
> # Branch stable
> # Node ID acfdfaf48d6fbb9bdcd8a0c922dfab0064c0b0b0
> # Parent 8ef0493ff30adc38cd0dfd3e1a8d5cb5b2366af0
> # EXP-Topic pin-pip
> ci: pin pytype to 2022.03.29

Queued for stable, thanks.
Reply all
Reply to author
Forward
0 new messages