Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jaraco/zipp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.19.2
Choose a base ref
...
head repository: jaraco/zipp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.19.3
Choose a head ref
  • 13 commits
  • 7 files changed
  • 3 contributors

Commits on Jun 21, 2024

  1. Copy the full SHA
    c9729e1 View commit details
  2. Merge https://github.com/jaraco/skeleton

    # Conflicts:
    #	pyproject.toml
    jaraco committed Jun 21, 2024
    Copy the full SHA
    04f5606 View commit details

Commits on Jul 10, 2024

  1. Copy the full SHA
    33c4896 View commit details

Commits on Jul 19, 2024

  1. "preserve" does not require preview any more (jaraco/skeleton#133)

    * "preserve" does not require preview any more
    * Update URL in ruff.toml comment
    
    ---------
    
    Co-authored-by: Bartosz Sławecki <bartoszpiotrslawecki@gmail.com>
    DimitriPapadopoulos and Bartosz Sławecki authored Jul 19, 2024
    Copy the full SHA
    f087fb4 View commit details
  2. Copy the full SHA
    30f940e View commit details
  3. Merge https://github.com/jaraco/skeleton

    jaraco committed Jul 19, 2024
    Copy the full SHA
    05d8b14 View commit details
  4. Copy the full SHA
    ab34814 View commit details
  5. Merge https://github.com/jaraco/skeleton

    jaraco committed Jul 19, 2024
    Copy the full SHA
    21c6bfd View commit details

Commits on Aug 11, 2024

  1. Copy the full SHA
    6f900ed View commit details
  2. Also match directories in Path.glob.

    Closes #121
    jaraco committed Aug 11, 2024
    Copy the full SHA
    5d89a1c View commit details
  3. Merge pull request #122 from jaraco/bugfix/121-glob-dirs

    Fix directory matching in glob
    jaraco authored Aug 11, 2024
    Copy the full SHA
    579be51 View commit details
  4. Narrow the versions under which Traversable is imported from importli…

    …b.abc. Fixes DeprecationWarning.
    jaraco committed Aug 11, 2024
    Copy the full SHA
    1184111 View commit details
  5. Finalize

    jaraco committed Aug 11, 2024
    Copy the full SHA
    9be5e12 View commit details
Showing with 40 additions and 10 deletions.
  1. +9 −0 NEWS.rst
  2. +2 −2 pyproject.toml
  3. +4 −2 ruff.toml
  4. +3 −3 tests/compat/py38.py
  5. +12 −0 tests/test_path.py
  6. +1 −2 zipp/__init__.py
  7. +9 −1 zipp/glob.py
9 changes: 9 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v3.19.3
=======

Bugfixes
--------

- Also match directories in Path.glob. (#121)


v3.19.2
=======

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ dependencies = [
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/jaraco/zipp"
Source = "https://github.com/jaraco/zipp"

[project.optional-dependencies]
test = [
@@ -32,7 +32,7 @@ test = [
"pytest-cov",
"pytest-mypy",
"pytest-enabler >= 2.2",
"pytest-ruff >= 0.2.1",
"pytest-ruff >= 0.2.1; sys_platform != 'cygwin'",

# local
"jaraco.itertools",
6 changes: 4 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[lint]
extend-select = [
"C901",
"PERF401",
"W",
]
ignore = [
@@ -22,7 +23,8 @@ ignore = [
]

[format]
# Enable preview, required for quote-style = "preserve"
# Enable preview to get hugged parenthesis unwrapping and other nice surprises
# See https://github.com/jaraco/skeleton/pull/133#issuecomment-2239538373
preview = true
# https://docs.astral.sh/ruff/settings/#format-quote-style
# https://docs.astral.sh/ruff/settings/#format_quote-style
quote-style = "preserve"
6 changes: 3 additions & 3 deletions tests/compat/py38.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys


if sys.version_info >= (3, 9):
from importlib.abc import Traversable
else: # pragma: no cover
if (3, 9) <= sys.version_info < (3, 11): # pragma: no cover
from importlib.abc import Traversable # type: ignore
elif sys.version_info < (3, 9): # pragma: no cover
from importlib_resources.abc import Traversable


12 changes: 12 additions & 0 deletions tests/test_path.py
Original file line number Diff line number Diff line change
@@ -469,6 +469,18 @@ def test_glob_recursive(self, alpharep):

assert list(root.glob("**/*.txt")) == list(root.rglob("*.txt"))

@pass_alpharep
def test_glob_dirs(self, alpharep):
root = zipfile.Path(alpharep)
assert list(root.glob('b')) == [zipfile.Path(alpharep, "b/")]
assert list(root.glob('b*')) == [zipfile.Path(alpharep, "b/")]

@pass_alpharep
def test_glob_subdir(self, alpharep):
root = zipfile.Path(alpharep)
assert list(root.glob('g/h')) == [zipfile.Path(alpharep, "g/h/")]
assert list(root.glob('g*/h*')) == [zipfile.Path(alpharep, "g/h/")]

@pass_alpharep
def test_glob_subdirs(self, alpharep):
root = zipfile.Path(alpharep)
3 changes: 1 addition & 2 deletions zipp/__init__.py
Original file line number Diff line number Diff line change
@@ -470,8 +470,7 @@ def glob(self, pattern):
prefix = re.escape(self.at)
tr = Translator(seps='/')
matches = re.compile(prefix + tr.translate(pattern)).fullmatch
names = (data.filename for data in self.root.filelist)
return map(self._next, filter(matches, names))
return map(self._next, filter(matches, self.root.namelist()))

def rglob(self, pattern):
return self.glob(f'**/{pattern}')
10 changes: 9 additions & 1 deletion zipp/glob.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ def translate(self, pattern):
"""
Given a glob pattern, produce a regex that matches it.
"""
return self.extend(self.translate_core(pattern))
return self.extend(self.match_dirs(self.translate_core(pattern)))

def extend(self, pattern):
r"""
@@ -41,6 +41,14 @@ def extend(self, pattern):
"""
return rf'(?s:{pattern})\Z'

def match_dirs(self, pattern):
"""
Ensure that zipfile.Path directory names are matched.
zipfile.Path directory names always end in a slash.
"""
return rf'{pattern}[/]?'

def translate_core(self, pattern):
r"""
Given a glob pattern, produce a regex that matches it.