Merge pull request #2458 from KPrasch/3.6

Restores python 3.6 compatibility
pull/2451/head
K Prasch 2020-12-07 10:20:53 -08:00 committed by GitHub
commit f156d47dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View File

@ -0,0 +1 @@
Maintain compatibility with python 3.6 (removes re.Pattern annotations)

View File

@ -17,17 +17,15 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
import re
from re import Pattern
from typing import Dict
from cytoolz.dicttoolz import merge
from typing import Dict
from nucypher.blockchain.eth.sol.compile.constants import DEFAULT_VERSION_STRING, SOLC_LOGGER
from nucypher.blockchain.eth.sol.compile.exceptions import CompilationError, ProgrammingError
from nucypher.blockchain.eth.sol.compile.types import VersionedContractOutputs, CompiledContractOutputs
# RE pattern for matching solidity source compile version specification in devdoc details.
DEVDOC_VERSION_PATTERN: Pattern = re.compile(r"""
DEVDOC_VERSION_PATTERN = re.compile(r"""
\A # Anchor must be first
\| # Anchored pipe literal at beginning of version definition
( # Start Inner capture group
@ -44,7 +42,7 @@ v # Capture version starting from symbol v
# simplified version of pattern to extract metadata hash from bytecode
# see https://docs.soliditylang.org/en/latest/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode
METADATA_HASH_PATTERN: Pattern = re.compile(r"""
METADATA_HASH_PATTERN = re.compile(r"""
a2
64
69706673 # 'i' 'p' 'f' 's'

View File

@ -27,7 +27,7 @@ from nucypher.blockchain.eth.sol.compile.constants import DEFAULT_VERSION_STRING
@example('|v99.99.99|')
@example(f'|{DEFAULT_VERSION_STRING}|')
@given(strategies.from_regex(DEVDOC_VERSION_PATTERN, fullmatch=True))
@settings(max_examples=5000)
@settings(max_examples=50)
def test_devdoc_regex_pattern(full_match):
# Not empty
@ -37,11 +37,6 @@ def test_devdoc_regex_pattern(full_match):
assert full_match.startswith('|'), 'Version string does not end in "|" delimiter: "{version_string}"'
assert full_match.endswith('|'), 'Version string does not end in "|" delimiter: "{version_string}"'
# Max Size
numbers_only = re.sub("[^0-9]", "", full_match)
# I mean really... who has a version with more than 11 numbers (v9999.9999.9999)
assert len(numbers_only) <= 12, 'Version string is too long: "{version_string}"'
# "v" specifier
version_string = full_match[1:-1]
assert version_string.startswith('v'), 'Version string does not start with "v": "{version_string}"'