Rename to scryfall-py

This commit is contained in:
zevaryx 2025-03-01 20:31:25 -07:00
parent 11d5669556
commit 96ed423f0a
26 changed files with 57 additions and 54 deletions

View file

@ -6,7 +6,7 @@ on:
- published
env:
PACKAGE_NAME: pyfall
PACKAGE_NAME: scryfall
jobs:
build-and-publish:

View file

@ -1,3 +1,3 @@
# Pyfall
# Scryfall-py
An async Scryfall API wrapper written in Python

View file

@ -1,3 +0,0 @@
from pyfall.client import Pyfall
__all__ = ["Pyfall"]

View file

@ -1,5 +1,5 @@
[project]
name = "pyfall"
name = "scryfall-py"
version = "0.1.0"
description = "An async Scryfall API wrapper"
license = { text = "MIT License" }
@ -38,6 +38,9 @@ dev = [
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["scryfall"]
[tool.pytest.ini_options]
minversion = "8.0"
testpaths = ["tests"]

3
scryfall/__init__.py Normal file
View file

@ -0,0 +1,3 @@
from scryfall.client import Scryfall
__all__ = ["Scryfall"]

View file

@ -1,6 +1,6 @@
from typing import Any
from pyfall.const import __version__
from scryfall.const import __version__
import asyncio
import logging
@ -8,11 +8,11 @@ import time
from httpx import AsyncClient
from pyfall.const import get_logger
from pyfall.client.error import LibraryException, HTTPException, ScryfallError, Forbidden, NotFound
from pyfall.client.http.http_requests.card import CardRequests
from pyfall.client.http.http_requests.set import SetRequests
from pyfall.client.route import Route
from scryfall.const import get_logger
from scryfall.client.error import LibraryException, HTTPException, ScryfallError, Forbidden, NotFound
from scryfall.client.http.http_requests.card import CardRequests
from scryfall.client.http.http_requests.set import SetRequests
from scryfall.client.route import Route
class GlobalLock:
@ -51,11 +51,11 @@ class GlobalLock:
self._calls -= 1
class Pyfall(CardRequests, SetRequests):
class Scryfall(CardRequests, SetRequests):
def __init__(self, logger: logging.Logger | None = None):
self.__headers = {
"Content-Type": "application/json",
"UserAgent": f"pyfall/{__version__}",
"UserAgent": f"scryfall/{__version__}",
"Accept": "application/json",
}
self.__client: AsyncClient = None # type: ignore

View file

@ -3,11 +3,11 @@ from typing import TYPE_CHECKING
import httpx
if TYPE_CHECKING:
from pyfall.client.route import Route
from scryfall.client.route import Route
class LibraryException(Exception):
"""Base Exception of pyfall."""
"""Base Exception of scryfall-py."""
class HTTPException(LibraryException):

View file

@ -1,12 +1,12 @@
from typing import Any, Literal
from uuid import UUID
from pyfall.models.catalogs import Catalog
from pyfall.client.route import Route
from pyfall.models.cards import Card
from pyfall.models.api import APIList
from pyfall.models.rulings import Ruling
from pyfall.models.internal.protocols import CanRequest
from scryfall.models.catalogs import Catalog
from scryfall.client.route import Route
from scryfall.models.cards import Card
from scryfall.models.api import APIList
from scryfall.models.rulings import Ruling
from scryfall.models.internal.protocols import CanRequest
class CardRequests(CanRequest):

View file

@ -1,9 +1,9 @@
from uuid import UUID
from pyfall.client.route import Route
from pyfall.models.api import APIList
from pyfall.models.sets import Set
from pyfall.models.internal.protocols import CanRequest
from scryfall.client.route import Route
from scryfall.models.api import APIList
from scryfall.models.sets import Set
from scryfall.models.internal.protocols import CanRequest
class SetRequests(CanRequest):

View file

@ -2,7 +2,7 @@ import logging
__version__ = "0.1.0"
logger_name = "pyfall"
logger_name = "scryfall"
_logger = logging.getLogger(logger_name)

View file

@ -2,11 +2,11 @@ from typing import Any, Literal
from pydantic import BaseModel, HttpUrl, ValidationError, model_validator
from pyfall.models.base import BaseAPIModel
from pyfall.models.cards import Card
from pyfall.models.rulings import Ruling
from pyfall.models.sets import Set
from pyfall.models.symbols import CardSymbol
from scryfall.models.base import BaseAPIModel
from scryfall.models.cards import Card
from scryfall.models.rulings import Ruling
from scryfall.models.sets import Set
from scryfall.models.symbols import CardSymbol
CLASS_LOOKUP = {"card": Card, "card_symbol": CardSymbol, "ruling": Ruling, "set": Set}

View file

@ -3,15 +3,15 @@ from typing import TYPE_CHECKING
from pydantic import BaseModel
if TYPE_CHECKING:
from pyfall.client import Pyfall
from scryfall.client import Scryfall
class BaseAPIModel(BaseModel):
"""Base API model for base API calls."""
_client: "Pyfall"
_client: "Scryfall"
def __init__(self, **data):
client: "Pyfall" = data["_client"]
client: "Scryfall" = data["_client"]
super().__init__(**data)
self._client = client

View file

@ -4,12 +4,12 @@ from uuid import UUID
from pydantic import BaseModel, HttpUrl, field_validator
from pyfall.models.base import BaseAPIModel
from pyfall.models.enums import Color
from scryfall.models.base import BaseAPIModel
from scryfall.models.enums import Color
if TYPE_CHECKING:
from pyfall.models.rulings import Ruling
from pyfall.models.sets import Set
from scryfall.models.rulings import Ruling
from scryfall.models.sets import Set
class RelatedCard(BaseModel):

View file

@ -1,7 +1,7 @@
import typing
from typing import Protocol, Any, TypeVar
from pyfall.client.route import Route
from scryfall.client.route import Route
T_co = TypeVar("T", covariant=True) # type: ignore

View file

@ -4,10 +4,10 @@ from uuid import UUID
from pydantic import HttpUrl
from pyfall.models.base import BaseAPIModel
from scryfall.models.base import BaseAPIModel
if TYPE_CHECKING:
from pyfall.models.api import APIList
from scryfall.models.api import APIList
class Set(BaseAPIModel):

View file

@ -2,7 +2,7 @@ from typing import Literal
from pydantic import BaseModel, HttpUrl
from pyfall.models.enums import Color
from scryfall.models.enums import Color
class CardSymbol(BaseModel):

View file

@ -1,6 +1,6 @@
import pytest
from pyfall import Pyfall
from scryfall import Scryfall
test_card_uuid = "1e90c638-d4b2-4243-bbc4-1cc10516c40f"
test_card_name = "Arcades, the Strategist"
@ -8,7 +8,7 @@ test_card_name = "Arcades, the Strategist"
@pytest.mark.asyncio
async def test_get_card_by_all_ids():
client = Pyfall()
client = Scryfall()
card = await client.get_card_by_id(test_card_uuid)
assert card.name == test_card_name
@ -29,7 +29,7 @@ async def test_get_card_by_all_ids():
@pytest.mark.asyncio
async def test_get_card_rulings():
client = Pyfall()
client = Scryfall()
card = await client.get_card_by_id(test_card_uuid)
rulings = await card.get_rulings()
@ -38,7 +38,7 @@ async def test_get_card_rulings():
@pytest.mark.asyncio
async def test_search_card_all():
client = Pyfall()
client = Scryfall()
with pytest.raises(ValueError):
_ = await client.search_cards(q="_" * 1001)
@ -63,7 +63,7 @@ async def test_search_card_all():
@pytest.mark.asyncio
async def test_cards_autocomplete():
client = Pyfall()
client = Scryfall()
catalog = await client.cards_autocomplete(q="avacyn")
@ -72,7 +72,7 @@ async def test_cards_autocomplete():
@pytest.mark.asyncio
async def test_get_random_card():
client = Pyfall()
client = Scryfall()
card = await client.get_random_card()
assert card is not None
@ -80,7 +80,7 @@ async def test_get_random_card():
@pytest.mark.asyncio
async def test_card_set():
client = Pyfall()
client = Scryfall()
card = await client.get_card_by_id(test_card_uuid)
card_set = await card.get_set()

View file

@ -1,6 +1,6 @@
import pytest
from pyfall import Pyfall
from scryfall import Scryfall
test_set_uuid = "2f5f2509-56db-414d-9a7e-6e312ec3760c"
test_set_name = "Core Set 2019"
@ -9,13 +9,13 @@ test_set_code = "m19"
@pytest.mark.asyncio
async def test_get_all_sets():
client = Pyfall()
client = Scryfall()
_ = await client.get_all_sets()
@pytest.mark.asyncio
async def test_get_set():
client = Pyfall()
client = Scryfall()
set_ = await client.get_set_by_id(test_set_uuid)
assert set_.name == test_set_name

2
uv.lock generated
View file

@ -717,7 +717,7 @@ wheels = [
]
[[package]]
name = "pyfall"
name = "scryfall"
version = "0.1.0"
source = { editable = "." }
dependencies = [