Skip to content

Commit

Permalink
Rely on singledispatch backport for Python 3.6 compatibility.
Browse files Browse the repository at this point in the history
jaraco committed Feb 21, 2021

Verified

This commit was signed with the committer’s verified signature.
Mamaduka George Mamadashvili
1 parent 3c33945 commit 9ef9636
Showing 2 changed files with 5 additions and 18 deletions.
21 changes: 3 additions & 18 deletions jaraco/path.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

import os
import re
import sys
import itertools
import functools
import calendar
@@ -19,6 +18,8 @@
import pathlib
from typing import Dict, Union

from singledispatch import singledispatch


log = logging.getLogger(__name__)

@@ -306,7 +307,7 @@ def build(spec: FilesSpec, prefix=pathlib.Path()):
create(contents, pathlib.Path(prefix) / name)


@functools.singledispatch
@singledispatch
def create(content: dict, path):
path.mkdir(exist_ok=True)
build(content, prefix=path)
@@ -320,19 +321,3 @@ def _(content: bytes, path):
@create.register # type: ignore[no-redef]
def _(content: str, path):
path.write_text(content)


if sys.version_info < (3, 7):

@create.register(dict) # type: ignore[no-redef]
def _(content, path):
path.mkdir(exist_ok=True)
build(content, prefix=path)

@create.register(bytes) # type: ignore[no-redef]
def _(content, path):
path.write_bytes(content)

@create.register(str) # type: ignore[no-redef]
def _(content, path):
path.write_text(content)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ include_package_data = true
python_requires = >=3.6
install_requires =
pyobjc; platform_system == "Darwin"
# until Python 3.6 is dropped
singledispatch >= 3.6
setup_requires = setuptools_scm[toml] >= 3.4.1

[options.packages.find]

0 comments on commit 9ef9636

Please sign in to comment.