diff mercurial/wireprototypes.py @ 51788:278af66e6595

typing: induce pytype to use the standard `attr` instead of the vendored copy What was previously happening with the vendored copy was that pytype would stub out all(?) classes that were decorated with `@attr.s` as `Any`. After this, we get a ton of classes defined, and numerous fields and methods now have proper types.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 23 Jul 2024 19:20:22 -0400
parents 18c8c18993f0
children f4733654f144
line wrap: on
line diff
--- a/mercurial/wireprototypes.py	Tue Jul 23 19:14:16 2024 -0400
+++ b/mercurial/wireprototypes.py	Tue Jul 23 19:20:22 2024 -0400
@@ -4,12 +4,20 @@
 # GNU General Public License version 2 or any later version.
 
 
+import typing
+
 from .node import (
     bin,
     hex,
 )
 from .i18n import _
 from .thirdparty import attr
+
+# Force pytype to use the non-vendored package
+if typing.TYPE_CHECKING:
+    # noinspection PyPackageRequirements
+    import attr
+
 from . import (
     error,
     util,