Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal typing (and assorted cleanups) #266

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 27 additions & 94 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ jobs:
os:
- ubuntu-20.04
python-version:
# - 2.7
# - 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- "3.8"
- "3.9"
- "3.10"
- 3.11
- 3.12
# - pypy-2.7
- pypy-3.8
- pypy-3.9
- pypy-3.10
- "3.11"
- "3.12"
- "pypy-3.8"
- "pypy-3.9"
- "pypy-3.10"
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -40,7 +35,7 @@ jobs:
- name: Update pip
run: python -m pip install -U pip wheel setuptools
- name: Install tox
run: python -m pip install "tox<4.0.0" "tox-gh-actions<3.0.0"
run: python -m pip install tox tox-gh-actions
- name: Test with tox
run: python -m tox
- name: Store partial coverage reports
Expand All @@ -55,7 +50,6 @@ jobs:
# strategy:
# matrix:
# python:
# #- {os: ubuntu-20.04, python-version: 3.7, pyver: py37}
# #- {os: ubuntu-20.04, python-version: 3.8, pyver: py38}
# #- {os: ubuntu-20.04, python-version: 3.9, pyver: py39}
# - {os: ubuntu-20.04, python-version: "3.10", pyver: py310}
Expand All @@ -79,7 +73,7 @@ jobs:
# ${{ env.py }} -m venv .env && \
# source .env/bin/activate && \
# pip install -U pip wheel setuptools && \
# pip install "tox<4.0.0" "tox-gh-actions<3.0.0" && \
# pip install tox tox-gh-actions && \
# tox -e ${{ matrix.python.pyver }} && \
# deactivate'

Expand All @@ -91,19 +85,14 @@ jobs:
os:
- macos-latest
python-version:
# - 2.7
# - 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- "3.8"
- "3.9"
- "3.10"
- 3.11
- 3.12
# - pypy-2.7
- pypy-3.8
- pypy-3.9
- pypy-3.10
- "3.11"
- "3.12"
- "pypy-3.8"
- "pypy-3.9"
- "pypy-3.10"
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -114,7 +103,7 @@ jobs:
- name: Update pip
run: python -m pip install -U pip wheel setuptools
- name: Install tox
run: python -m pip install "tox<4.0.0" "tox-gh-actions<3.0.0"
run: python -m pip install tox tox-gh-actions
- name: Test with tox
run: python -m tox
- name: Store partial coverage reports
Expand All @@ -123,29 +112,6 @@ jobs:
name: coverage
path: .coverage.*

# test_windows_py27:
# name: Test (${{ matrix.os }}, ${{ matrix.python-version }})
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os:
# - windows-latest
# python-version:
# - 2.7
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Setup Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Update pip
# run: python -m pip install -U pip wheel setuptools
# - name: Install tox
# run: python -m pip install "tox<4.0.0" "tox-gh-actions<3.0.0"
# - name: Test with tox
# run: python -m tox -e py27,py27-without-extensions

test_windows:
name: Test (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
Expand All @@ -154,18 +120,14 @@ jobs:
os:
- windows-latest
python-version:
# - 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- "3.8"
- "3.9"
- "3.10"
- 3.11
- 3.12
# - pypy-2.7
- pypy-3.8
- pypy-3.9
- pypy-3.10
- "3.11"
- "3.12"
- "pypy-3.8"
- "pypy-3.9"
- "pypy-3.10"
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -176,7 +138,7 @@ jobs:
- name: Update pip
run: python -m pip install -U pip wheel setuptools
- name: Install tox
run: python -m pip install "tox<4.0.0" "tox-gh-actions<3.0.0"
run: python -m pip install tox tox-gh-actions
- name: Test with tox
run: python -m tox

Expand Down Expand Up @@ -208,40 +170,12 @@ jobs:
name: dist
path: dist/*

# bdist_wheel_legacy:
# name: Build wheels (2.7-3.5) on ${{ matrix.os }}
# needs:
# - test_linux
# - test_macos
# - test_windows_py27
# - test_windows
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-20.04, windows-latest, macos-latest]
# steps:
# - uses: actions/checkout@v3
# - name: Build wheels
# uses: pypa/[email protected]
# with:
# output-dir: dist
# env:
# WRAPT_INSTALL_EXTENSIONS: true
# CIBW_BUILD: cp27* cp35*
# CIBW_SKIP: cp27-win*
# CIBW_BUILD_VERBOSITY: 1
# - uses: actions/upload-artifact@v3
# with:
# name: dist
# path: dist/*.whl

bdist_wheel:
name: Build wheels (3.6+) on ${{ matrix.os }} for ${{ matrix.arch }}
name: Build wheels on ${{ matrix.os }} for ${{ matrix.arch }}
needs:
- test_linux
#- test_aarch64_linux
- test_macos
# - test_windows_py27
- test_windows
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -259,7 +193,7 @@ jobs:
if: ${{ matrix.arch == 'aarch64' }}
uses: docker/setup-qemu-action@v2
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.19.2
with:
output-dir: dist
env:
Expand All @@ -278,7 +212,6 @@ jobs:
needs:
- test_linux
- test_macos
# - test_windows_py27
- test_windows
runs-on: ubuntu-20.04
steps:
Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
hooks:
- id: mypy
exclude: |
(?x)(
tests/.*
| docs/.*
)
additional_dependencies:
- "types-setuptools"
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ other functions.
.. code-block:: python

import wrapt

@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)
Expand Down Expand Up @@ -98,7 +98,7 @@ The above rules can be summarised with the following example.
.. code-block:: python

import inspect

@wrapt.decorator
def universal(wrapped, instance, args, kwargs):
if instance is None:
Expand Down
2 changes: 0 additions & 2 deletions blog/14-automatic-patching-of-python-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ name of the entry point defined in the setup.py file for autowrapt.
The actual code for the `autowrapt_this()` function was:

```python
from __future__ import print_function

def autowrapt_this(module):
print('The wrapt package is absolutely amazing and you should use it.')
```
Expand Down
10 changes: 9 additions & 1 deletion docs/benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
import wrapt # https://pypi.python.org/pypi/wrapt
import decorator # https://pypi.python.org/pypi/decorator


def function1():
pass


def wrapper2(func):
def _wrapper2(*args, **kwargs):
return func(*args, **kwargs)

return _wrapper2


@wrapper2
def function2():
pass


@wrapt.decorator
def wrapper3(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)


@wrapper3
def function3():
pass


@decorator.decorator
def wrapper4(wrapped, *args, **kwargs):
return wrapped(*args, **kwargs)


@wrapper4
def function4():
pass

class Class(object):

class Class(object):
def function1(self):
pass

Expand Down
4 changes: 2 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Version 1.11.0
result in an exception being raised to indicate that a proxy object had
not been initialised when in fact the argument wasn't even an instance
of a proxy object.

Because an incorrect cast in C level code was being performed and
an attribute in memory checked on the basis of it being a type different
to what it actually was, technically it may have resulted in a process
Expand Down Expand Up @@ -574,7 +574,7 @@ Version 1.10.0
* The ``inspect.signature()`` function was only added in Python 3.3.
Use fallback when doesn't exist and on Python 3.2 or earlier Python 3
versions.

Note that testing is only performed for Python 3.3+, so it isn't
actually known if the ``wrapt`` package works on Python 3.2.

Expand Down
Loading
Loading