Skip to content

Commit

Permalink
🚚 Rename PEP.from_json to PEP.from_api
Browse files Browse the repository at this point in the history
While the data from the API is JSON data, I want a method of loading data
from what comes from the API and another for data that comes from the local
storage, which for now will be JSON.
  • Loading branch information
davep committed Jan 26, 2025
1 parent ee68578 commit 5156d92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/peplum/app/data/pep.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def _authors(cls, authors: str) -> tuple[str, ...]:
return tuple(author.strip() for author in cls._AUTHOR_SPLIT.split(authors))

@classmethod
def from_json(cls, data: dict[str, Any]) -> PEP:
"""Create a PEP from the given JSON data.
def from_api(cls, data: dict[str, Any]) -> PEP:
"""Create a PEP from the given API data.
Args:
data: The data to create the object from.
Expand Down
4 changes: 2 additions & 2 deletions src/peplum/app/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def load_pep_data(self) -> None:
self.post_message(
self.Loaded(
PEPs(
PEP.from_json(pep)
PEP.from_api(pep)
for pep in loads(pep_data().read_text()).values()
)
)
Expand All @@ -221,7 +221,7 @@ async def download_pep_data(self) -> None:
except IOError as error:
self.notify(str(error), title="Error saving PEP data", severity="error")
self.post_message(
self.Loaded(PEPs(PEP.from_json(pep) for pep in raw_data.values()))
self.Loaded(PEPs(PEP.from_api(pep) for pep in raw_data.values()))
)

@on(Loaded)
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

##############################################################################
SAMPLE_PEPS: Final[tuple[PEP, ...]] = (
PEP.from_json(
PEP.from_api(
{
"number": 1,
"title": "PEP Purpose and Guidelines",
Expand All @@ -42,7 +42,7 @@
"url": "https://peps.python.org/pep-0001/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 458,
"title": "Secure PyPI downloads with signed repository metadata",
Expand All @@ -61,7 +61,7 @@
"url": "https://peps.python.org/pep-0458/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 467,
"title": "Minor API improvements for binary sequences",
Expand All @@ -80,7 +80,7 @@
"url": "https://peps.python.org/pep-0467/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 639,
"title": "Improving License Clarity with Better Package Metadata",
Expand All @@ -99,7 +99,7 @@
"url": "https://peps.python.org/pep-0639/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 213,
"title": "Attribute Access Handlers",
Expand All @@ -118,7 +118,7 @@
"url": "https://peps.python.org/pep-0213/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 204,
"title": "Range Literals",
Expand All @@ -137,7 +137,7 @@
"url": "https://peps.python.org/pep-0204/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 3,
"title": "Guidelines for Handling Bug Reports",
Expand All @@ -156,7 +156,7 @@
"url": "https://peps.python.org/pep-0003/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 100,
"title": "Python Unicode Integration",
Expand All @@ -175,7 +175,7 @@
"url": "https://peps.python.org/pep-0100/",
}
),
PEP.from_json(
PEP.from_api(
{
"number": 5,
"title": "Guidelines for Language Evolution",
Expand Down

0 comments on commit 5156d92

Please sign in to comment.