Skip to content

Commit 38b3abf

Browse files
authored
Merge pull request #88 from the-dotify-project/development
Development
2 parents a2601e8 + 2af3ad2 commit 38b3abf

File tree

13 files changed

+58
-86
lines changed

13 files changed

+58
-86
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,3 @@ jobs:
4747
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }}
4848
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }}
4949
run: poetry run python -m tox
50-
51-
docs:
52-
runs-on: ${{ matrix.platform }}
53-
strategy:
54-
matrix:
55-
platform: [ubuntu-latest, macos-latest, windows-latest]
56-
python-version: [3.7, 3.8, 3.9]
57-
steps:
58-
- uses: actions/checkout@v2
59-
60-
- name: Set up Python ${{ matrix.python-version }}
61-
uses: actions/setup-python@v2
62-
with:
63-
python-version: ${{ matrix.python-version }}
64-
65-
- name: Install Poetry
66-
uses: abatilo/[email protected]
67-
with:
68-
poetry-version: 1.1.6
69-
70-
- name: Configure Poetry
71-
run: |
72-
poetry config virtualenvs.in-project true
73-
74-
- name: Set up cache
75-
uses: actions/[email protected]
76-
with:
77-
path: |
78-
.tox
79-
.venv
80-
key: ${{ matrix.platform }}-tox-venv-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
81-
82-
- name: Install dependencies
83-
run: |
84-
poetry install
85-
86-
- name: Run MkDocs
87-
run: |
88-
poetry run python -m mkdocs build

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ repos:
5454
rev: v2.3
5555
hooks:
5656
- id: vulture
57+
- repo: https://github.com/tox-dev/tox-ini-fmt
58+
rev: 0.5.1
59+
hooks:
60+
- id: tox-ini-fmt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pip install dotify
9898

9999
## Contributing
100100

101-
If you would like to contribute to the project, please go through the [Contributing Guidelines](https://the-dotify-project.github.io/dotify/CONTRIBUTING/) first.
101+
If you would like to contribute to the project, please go through the [Contributing Guidelines](https://the-dotify-project.github.io/dotify/latest/CONTRIBUTING/) first.
102102

103103
## Contributors ✨
104104

docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PRs can be a quick way to get your fix or improvement slated for the next releas
3636
- Be accompanied by a complete Pull Request template (loaded automatically when a PR is created).
3737
- Add [unit or integration tests](https://github.com/the-dotify-project/dotify/tree/master/examples) for added or changed functionality.
3838
- Any code related changes should be accompanied by corresponding changes to the project's documentation.
39-
- If your pull request introduces a new feature, the corresponding `README` [section](https://the-dotify-project.github.io/dotify/#features) must be updated to reflect this. Make sure you also include [an example](https://github.com/the-dotify-project/dotify/tree/master/examples), showcasing this new functionality.
39+
- If your pull request introduces a new feature, the corresponding `README` [section](https://the-dotify-project.github.io/dotify/latest/#features) must be updated to reflect this. Make sure you also include [an example](https://github.com/the-dotify-project/dotify/tree/master/examples), showcasing this new functionality.
4040
- Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). [Why?](#writing-your-commit-message)
4141
- If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing.
4242

dotify/_json_serializable.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import json
22
import logging
33
from abc import ABCMeta
4-
from os import PathLike
5-
from typing import Any, Dict, Optional
4+
from typing import Any, Optional
65

76
from python_jsonschema_objects import ObjectBuilder
87
from python_jsonschema_objects.classbuilder import LiteralValue, ProtocolBase
@@ -44,17 +43,15 @@ def __new__(cls, name, bases, attrs): # noqa: D102
4443
class JsonSerializable(ProtocolBase, metaclass=JsonSerializableMeta):
4544
"""A class providing JSON serialization and de-serialization."""
4645

47-
class Json(object):
48-
schema: PathLike
49-
dependencies: Dict[str, "JsonSerializable"]
50-
5146
def __setattr__(self, name: str, val: Any) -> None:
5247
try:
5348
super().__setattr__(name, val)
5449
except ValidationError:
5550
if name in self.__annotations__:
5651
self.__dict__[name] = val
5752

53+
return
54+
5855
raise
5956

6057
def __getattribute__(self, name: str) -> Any:

dotify/_model.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,24 @@ class ModelMeta(JsonSerializableMeta):
2626
"""
2727

2828
def __new__(cls, name, bases, attrs): # noqa: D102
29-
if "Json" in attrs:
30-
attrs["Json"].schema = cls._dependency_path(name)
29+
json_meta = type("Json", (object,), {})
30+
with contextlib.suppress(KeyError):
31+
json_meta = attrs["Json"]
32+
33+
is_abstract = False
34+
with contextlib.suppress(AttributeError):
35+
is_abstract = json_meta.abstract
36+
37+
if not is_abstract:
38+
json_meta.schema = cls._dependency_path(name)
3139

3240
with contextlib.suppress(AttributeError):
33-
attrs["Json"].dependencies = cls._dependencies_from(
34-
attrs["Json"].dependencies,
41+
json_meta.dependencies = cls._dependencies_from(
42+
json_meta.dependencies,
3543
)
3644

45+
attrs["Json"] = json_meta
46+
3747
return super().__new__(cls, name, bases, attrs)
3848

3949
@classmethod
@@ -91,6 +101,9 @@ def decorator(_):
91101
class Model(JsonSerializable, metaclass=ModelMeta):
92102
"""The base class for every Spotify Web API entity."""
93103

104+
class Json(object):
105+
abstract = True
106+
94107
class UnexpectedError(Exception):
95108
"""An exception indicating an unexpected error."""
96109

dotify/models/_album.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
class AlbumBase(Model):
2222
"""`AlbumBase` defines the interface of the Album class, which is subclassing it."""
2323

24+
class Json(object):
25+
abstract = True
26+
2427
def __str__(self):
2528
return "{0} - {1}".format(self.artist, self.name)
2629

dotify/models/_artist.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
class Artist(Model):
1010
"""A class representing a Spotify `Artist`."""
1111

12-
class Json(object):
13-
""" """
14-
1512
@property
1613
def url(self) -> AnyStr:
1714
"""Return the artist's Spotify URL.

dotify/models/_image.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@
88
class Image(Model):
99
"""A class representing a Spotify `Image`."""
1010

11-
class Json(object):
12-
""" """
13-
1411
def __str__(self):
1512
return self.url

dotify/models/_playlist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
class PlaylistBase(Model):
1515
"""`PlaylistBase` defines the interface of the Playlist class, which is subclassing it."""
1616

17+
class Json(object):
18+
abstract = True
19+
1720
def __init__(self, **props) -> None: # noqa: D107
1821
props.pop("tracks", None)
1922

0 commit comments

Comments
 (0)