Skip to content

Commit

Permalink
Fix type annotation for re.Pattern
Browse files Browse the repository at this point in the history
In Python 3.6, re.Pattern is not a valid type and has to be replaced
with typing.Pattern:
    python/typeshed#3447

Fixes Nitrokey/pynitrokey#157
  • Loading branch information
robin-nitrokey committed Jan 20, 2022
1 parent 799e664 commit 05694d4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pynitrokey/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# copied, modified, or distributed except according to those terms.

import os.path
import re
import urllib.parse
from typing import BinaryIO, Callable, Dict, Generator, Optional
from typing import BinaryIO, Callable, Dict, Generator, Optional, Pattern

import requests

Expand Down Expand Up @@ -81,12 +80,12 @@ def __str__(self) -> str:
return self.tag

@classmethod
def _from_release(cls, release: dict, url_pattern: re.Pattern) -> "FirmwareUpdate":
def _from_release(cls, release: dict, url_pattern: Pattern) -> "FirmwareUpdate":
return cls._from_assets(release["assets"], release["tag_name"], url_pattern)

@classmethod
def _from_assets(
cls, assets: list, tag: str, url_pattern: re.Pattern
cls, assets: list, tag: str, url_pattern: Pattern
) -> "FirmwareUpdate":
urls = []
for asset in assets:
Expand All @@ -103,7 +102,7 @@ def _from_assets(


class Repository:
def __init__(self, owner: str, name: str, update_pattern: re.Pattern) -> None:
def __init__(self, owner: str, name: str, update_pattern: Pattern) -> None:
self.owner = owner
self.name = name
self.update_pattern = update_pattern
Expand Down

0 comments on commit 05694d4

Please sign in to comment.