Skip to content

Commit

Permalink
Fixing debian and python 3.7 tests issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry committed Mar 28, 2022
1 parent 98f0a75 commit c36cfc9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
21 changes: 18 additions & 3 deletions copier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import sys
from contextlib import suppress
from dataclasses import asdict, field, replace
from distutils.dir_util import copy_tree
from functools import partial
from itertools import chain
from pathlib import Path
from shutil import copyfile, copytree, rmtree
from typing import Callable, Iterable, List, Mapping, Optional, Sequence
from shutil import copyfile, rmtree
from typing import Callable, Iterable, List, Mapping, Optional, Sequence, Set
from unicodedata import normalize

import pathspec
Expand Down Expand Up @@ -40,9 +41,23 @@
# HACK https://github.com/python/mypy/issues/8520#issuecomment-772081075
if sys.version_info >= (3, 8):
from functools import cached_property

else:
from backports.cached_property import cached_property

# Backport of `shutil.copytree` for python 3.7 to accept `dirs_exist_ok` argument
if sys.version_info <= (3, 8):
from shutil import copytree
else:
from distutils.dir_util import copy_tree

def copytree(src: Path, dst: Path, dirs_exist_ok: bool = False):
"""Backport of `shutil.copytree` with `dirs_exist_ok` argument.
Can be remove once python 3.7 dropped.
"""
copy_tree(str(src), str(dst))


@dataclass
class Worker:
Expand Down Expand Up @@ -694,7 +709,7 @@ def run_update(self) -> None:
self.run_copy()

# Extract the list of files to merge
participating_files: set[Path] = set()
participating_files: Set[Path] = set()
for src_dir in (original_dst_temp, reference_dst_temp):
for root, dirs, files in os.walk(src_dir, topdown=True):
if root == src_dir and ".git" in dirs:
Expand Down
6 changes: 3 additions & 3 deletions docs/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ equivalent) hook that detects them, just like this:
```yaml title=".pre-commit-config.yaml"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-merge-conflict
rev: v4.0.1
hooks:
- id: check-merge-conflict
args: [--assume-in-merge]
```
Expand Down
1 change: 1 addition & 0 deletions tests/test_updatediff.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def test_updatediff(tmp_path_factory):
_src_path: {bundle}
author_name: Guybrush
project_name: to become a pirate\n
>>>>>>> new upstream
"""
)
assert readme.read_text() == dedent(
Expand Down

0 comments on commit c36cfc9

Please sign in to comment.