Skip to content

Commit

Permalink
Add official PyPy support (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laerte committed May 8, 2024
1 parent de8adc3 commit e710124
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: [push, pull_request]

jobs:
tests-ubuntu:
name: "Test: py${{ matrix.python-version }}, Ubuntu"
name: "Test: ${{ matrix.python-version }}, Ubuntu"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ a pre-defined interface (see [extending `itemadapter`](#extending-itemadapter)).

## Requirements

* Python 3.8+
* Python 3.8+, either the CPython implementation (default) or the PyPy implementation
* [`scrapy`](https://scrapy.org/): optional, needed to interact with `scrapy` items
* [`attrs`](https://pypi.org/project/attrs/): optional, needed to interact with `attrs`-based items
* [`pydantic`](https://pypi.org/project/pydantic/): optional, needed to interact with
Expand Down
10 changes: 8 additions & 2 deletions itemadapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def __setitem__(self, field_name: str, value: Any) -> None:
def __delitem__(self, field_name: str) -> None:
if field_name in self._fields_dict:
try:
delattr(self.item, field_name)
if hasattr(self.item, field_name):
delattr(self.item, field_name)
else:
raise AttributeError
except AttributeError:
raise KeyError(field_name)
else:
Expand Down Expand Up @@ -196,7 +199,10 @@ def __setitem__(self, field_name: str, value: Any) -> None:
def __delitem__(self, field_name: str) -> None:
if field_name in self.item.__fields__:
try:
delattr(self.item, field_name)
if hasattr(self.item, field_name):
delattr(self.item, field_name)
else:
raise AttributeError
except AttributeError:
raise KeyError(field_name)
else:
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Framework :: Scrapy",
"Intended Audience :: Developers",
"Topic :: Internet :: WWW/HTTP",
Expand Down

0 comments on commit e710124

Please sign in to comment.