Skip to content

Commit

Permalink
Merge branch 'main' into attempt_1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 8, 2022
2 parents f945f0a + c3b5c4e commit 6f2b8ca
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 42 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/*
*/pep517-build-env-*

[report]
show_missing = True
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ max_line_length = 88
[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.rst]
indent_style = space
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tidelift: pypi/zipp
39 changes: 30 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,63 @@ jobs:
strategy:
matrix:
python:
- 3.7
- 3.9
- "3.7"
- "3.10"
- "3.11"
# Workaround for actions/setup-python#508
dev:
- -dev
platform:
- ubuntu-latest
- macos-latest
- windows-latest
include:
- python: pypy3.9
platform: ubuntu-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# fetch all branches and tags (to get tags for versioning)
# ref actions/checkout#448
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python }}${{ matrix.dev }}
- name: Install tox
run: |
python -m pip install tox
- name: Run tests
run: tox

check: # This job does nothing and is only used for the branch protection
if: always()

needs:
- test

runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

release:
needs: test
needs:
- check
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11-dev
- name: Install tox
run: |
python -m pip install tox
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.6.0
hooks:
- id: black
7 changes: 7 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ python:
- path: .
extra_requirements:
- docs

# workaround for readthedocs/readthedocs.org#9623
build:
# workaround for readthedocs/readthedocs.org#9635
os: ubuntu-22.04
tools:
python: "3"
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v3.8.1
======

Refreshed packaging.

Enrolled with Tidelift.

v3.8.0
======

Expand Down
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
.. image:: https://img.shields.io/badge/skeleton-2022-informational
:target: https://blog.jaraco.com/skeleton

.. image:: https://tidelift.com/badges/package/pypi/zipp
:target: https://tidelift.com/subscription/pkg/pypi-zipp?utm_source=pypi-zipp&utm_medium=readme


A pathlib-compatible Zipfile object wrapper. Official backport of the standard library
`Path object <https://docs.python.org/3.8/library/zipfile.html#path-objects>`_.
Expand Down Expand Up @@ -49,3 +52,19 @@ Usage
=====

Use ``zipp.Path`` in place of ``zipfile.Path`` on any Python.

For Enterprise
==============

Available as part of the Tidelift Subscription.

This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.

`Learn more <https://tidelift.com/subscription/pkg/pypi-zipp?utm_source=pypi-zipp&utm_medium=referral&utm_campaign=github>`_.

Security Contact
================

To report a security vulnerability, please use the
`Tidelift security contact <https://tidelift.com/security>`_.
Tidelift will coordinate the fix and disclosure.
39 changes: 39 additions & 0 deletions _test_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import types
import functools

from more_itertools import always_iterable


def parameterize(names, value_groups):
"""
Decorate a test method to run it as a set of subtests.
Modeled after pytest.parametrize.
"""

def decorator(func):
@functools.wraps(func)
def wrapped(self):
for values in value_groups:
resolved = map(Invoked.eval, always_iterable(values))
params = dict(zip(always_iterable(names), resolved))
with self.subTest(**params):
func(self, **params)

return wrapped

return decorator


class Invoked(types.SimpleNamespace):
"""
Wrap a function to be invoked for each usage.
"""

@classmethod
def wrap(cls, func):
return cls(func=func)

@classmethod
def eval(cls, cand):
return cand.func() if isinstance(cand, cls) else cand
17 changes: 14 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker']
extensions = [
'sphinx.ext.autodoc',
'jaraco.packaging.sphinx',
]

master_doc = "index"
html_theme = "furo"

# Link dates and other references in the changelog
extensions += ['rst.linker']
link_files = {
'../CHANGES.rst': dict(
using=dict(GH='https://github.com'),
Expand All @@ -19,7 +25,7 @@
),
dict(
pattern=r'PEP[- ](?P<pep_number>\d+)',
url='https://www.python.org/dev/peps/pep-{pep_number:0>4}/',
url='https://peps.python.org/pep-{pep_number:0>4}/',
),
dict(
pattern=r'(Python #|bpo-)(?P<python>\d+)',
Expand All @@ -29,7 +35,7 @@
)
}

# Be strict about any broken references:
# Be strict about any broken references
nitpicky = True

# Include Python intersphinx mapping to prevent failures
Expand All @@ -38,3 +44,8 @@
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}

# Preserve authored syntax for defaults
autodoc_preserve_defaults = True

extensions += ['jaraco.tidelift']
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Welcome to |project| documentation!
history


.. tidelift-referral-banner::

.. automodule:: zipp
:members:
:undoc-members:
Expand All @@ -19,4 +21,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ skip-string-normalization = true

[tool.setuptools_scm]

[pytest.enabler.black]
[tool.pytest-enabler.black]
addopts = "--black"

[pytest.enabler.mypy]
[tool.pytest-enabler.mypy]
addopts = "--mypy"

[pytest.enabler.flake8]
[tool.pytest-enabler.flake8]
addopts = "--flake8"

[pytest.enabler.cov]
[tool.pytest-enabler.cov]
addopts = "--cov"
10 changes: 8 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,30 @@ testing =
pytest >= 6
pytest-checkdocs >= 2.4
pytest-flake8
# workaround for tholo/pytest-flake8#87
flake8 < 5
pytest-black >= 0.3.7; \
# workaround for jaraco/skeleton#22
python_implementation != "PyPy"
pytest-cov
pytest-mypy >= 0.9.1; \
# workaround for jaraco/skeleton#22
python_implementation != "PyPy"
pytest-enabler >= 1.0.1
pytest-enabler >= 1.3

# local
jaraco.itertools
func-timeout
jaraco.functools
more_itertools

docs =
# upstream
sphinx
sphinx >= 3.5
jaraco.packaging >= 9
rst.linker >= 1.9
furo
jaraco.tidelift >= 1.4

# local

Expand Down
35 changes: 13 additions & 22 deletions test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import tempfile
import shutil
import string
import functools
import pickle

import jaraco.itertools
import func_timeout
from jaraco.functools import compose

import zipp

from _test_params import parameterize, Invoked


consume = tuple


Expand Down Expand Up @@ -72,31 +75,20 @@ def temp_dir():
shutil.rmtree(tmpdir)


def pass_alpharep(meth):
"""
Given a method, wrap it in a for loop that invokes method
with each subtest.
"""

@functools.wraps(meth)
def wrapper(self):
for alpharep in self.zipfile_alpharep():
meth(self, alpharep=alpharep)

return wrapper
pass_alpharep = parameterize(
['alpharep'],
[
Invoked.wrap(build_alpharep_fixture),
Invoked.wrap(compose(add_dirs, build_alpharep_fixture)),
],
)


class TestPath(unittest.TestCase):
def setUp(self):
self.fixtures = contextlib.ExitStack()
self.addCleanup(self.fixtures.close)

def zipfile_alpharep(self):
with self.subTest():
yield build_alpharep_fixture()
with self.subTest():
yield add_dirs(build_alpharep_fixture())

def zipfile_ondisk(self, alpharep):
tmpdir = pathlib.Path(self.fixtures.enter_context(temp_dir()))
buffer = alpharep.fp
Expand Down Expand Up @@ -414,9 +406,8 @@ def test_root_unnamed(self, alpharep):
@pass_alpharep
def test_inheritance(self, alpharep):
cls = type('PathChild', (zipp.Path,), {})
for alpharep in self.zipfile_alpharep():
file = cls(alpharep).joinpath('some dir').parent
assert isinstance(file, cls)
file = cls(alpharep).joinpath('some dir').parent
assert isinstance(file, cls)

@pass_alpharep
def test_can_pickle_string_path(self, alpharep):
Expand Down

0 comments on commit 6f2b8ca

Please sign in to comment.