Skip to content

Commit

Permalink
Add Python 3.8 compatibility to type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 9, 2023
1 parent 0bea1bd commit f39b17c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
omit =
# leading `*/` for pytest-dev/pytest-cov#456
*/.tox/*
*/compat/*
disable_warnings =
couldnt-parse

Expand Down
6 changes: 4 additions & 2 deletions jaraco/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import copy
import functools
import random
from collections.abc import Container, Iterable, Mapping, MutableMapping
from collections.abc import Container, Iterable, Mapping
from typing import Any, Callable, Union

import jaraco.text
from more_itertools import consume

from .compat.py38 import MutableMapping


_Matchable = Union[Callable, Container, Iterable, re.Pattern]

Expand Down Expand Up @@ -1058,7 +1060,7 @@ def random(self):


def remove_matching(
orig: MutableMapping[str, Any],
orig: MutableMapping,
predicate: _Matchable,
):
"""
Expand Down
8 changes: 8 additions & 0 deletions jaraco/collections/compat/py38.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import collections.abc
import sys
import typing

if sys.version_info >= (3, 9):
MutableMapping = collections.abc.MutableMapping
else:
MutableMapping = typing.MutableMapping

0 comments on commit f39b17c

Please sign in to comment.