backport 1e9cf75dcc28c6 to fix py-hypothesis on py2 following py-typing update

(hypothesis could probably be updated to 4.57.1 without trouble; 5.x is py3-only)
This commit is contained in:
sthen 2020-01-03 14:51:21 +00:00
parent ed91e60e6c
commit 509b04aafb
2 changed files with 28 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.20 2019/07/12 20:45:49 sthen Exp $
# $OpenBSD: Makefile,v 1.21 2020/01/03 14:51:21 sthen Exp $
COMMENT = library for property based testing
@ -6,7 +6,7 @@ MODPY_EGG_VERSION = 4.15.0
DISTNAME = hypothesis-${MODPY_EGG_VERSION}
PKGNAME = py-hypothesis-${MODPY_EGG_VERSION}
CATEGORIES = devel
REVISION = 0
REVISION = 1
HOMEPAGE = https://hypothesis.works/

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-src_hypothesis_internal_compat_py,v 1.1 2020/01/03 14:51:21 sthen Exp $
From 1e9cf75dcc28c6b0c7c211a20e49257a4e052c84 Mon Sep 17 00:00:00 2001
From: Zac Hatfield-Dodds <Zac-HD@users.noreply.github.com>
Date: Fri, 21 Jun 2019 12:19:15 +1000
Subject: [PATCH] Support newer typing backport too
Index: src/hypothesis/internal/compat.py
--- src/hypothesis/internal/compat.py.orig
+++ src/hypothesis/internal/compat.py
@@ -298,10 +298,13 @@ except ImportError:
typing_root_type = () # type: Tuple[type, ...]
ForwardRef = None
else:
- if hasattr(typing, "_Final"): # new in Python 3.7
+ try:
+ # These types are new in Python 3.7, but also (partially) backported to the
+ # typing backport on PyPI. Use if possible; or fall back to older names.
+
typing_root_type = (typing._Final, typing._GenericAlias) # type: ignore
ForwardRef = typing.ForwardRef # type: ignore
- else:
+ except AttributeError:
typing_root_type = (typing.TypingMeta, typing.TypeVar) # type: ignore
ForwardRef = typing._ForwardRef # type: ignore