Skip to content

Commit

Permalink
Add python3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
markovejnovic committed Dec 4, 2023
1 parent b46a454 commit bbe6526
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ autolint:
$(PYTHON) -m ruff check --fix .

test:
$(PYTHON) -m pytest \
$(PYTHON) -m pytest tests \
--cov=aiomarketstack \
--cov-report=html \
--cov-report=term
Expand Down
15 changes: 12 additions & 3 deletions aiomarketstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@
from __future__ import annotations

import warnings
from datetime import date, datetime
from datetime import date, datetime, timezone
from enum import IntEnum
from typing import (
TYPE_CHECKING,
AsyncGenerator,
Callable,
Collection,
Literal,
Self,
)

import aiohttp
import structlog
from aiohttp import ClientResponse, ClientSession

if TYPE_CHECKING:
from typing_extensions import Self

from aiomarketstack.exceptions import (
ForbiddenError,
FunctionAccessRestrictedError,
Expand Down Expand Up @@ -306,9 +308,16 @@ def _deserialize_eod(raw_eod: RawEod) -> Eod:
"dividend": raw_eod["dividend"],
"symbol": raw_eod["symbol"],
"exchange": raw_eod["exchange"],
"date": datetime.fromisoformat(raw_eod["date"]).date(),
"date": _MarketstackClient._parse_marketstack_date(raw_eod["date"]),
}

@staticmethod
def _parse_marketstack_date(date_str: str) -> date:
# Necessary because python < 3.11's fromisoformat didn't support IS8601.
marketstack_date_format = "%Y-%m-%dT%H:%M:%S%z"
return datetime.strptime(date_str, marketstack_date_format) \
.replace(tzinfo=timezone.utc).date()


class HttpMarketstackClient(_MarketstackClient):
"""The main marketstack client.
Expand Down
2 changes: 1 addition & 1 deletion aiomarketstack/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Marketstack Error Response Errors."""

from typing import Self

from aiohttp.client import ClientResponse
from typing_extensions import Self


class ResponseError(Exception):
Expand Down
4 changes: 3 additions & 1 deletion aiomarketstack/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from __future__ import annotations

from typing import TYPE_CHECKING, NotRequired, Required, Sequence, TypedDict
from typing import TYPE_CHECKING, Sequence, TypedDict

if TYPE_CHECKING:
from datetime import date

from typing_extensions import NotRequired, Required


class Eod(TypedDict):
"""Represents an end-of-day marketstack return type."""
Expand Down
72 changes: 32 additions & 40 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ readme = "README.md"
packages = [{ include = "aiomarketstack" }]

[tool.poetry.dependencies]
aiohttp = "^3.7.3"
python = "^3.9"
structlog = "^23.1.0"
python = "^3.8"
aiohttp = {version = "^3.9.1", python = "^3.8"}
structlog = {version = "^23.2.0", python = "^3.8"}
typing-extensions = {version = "^4.8.0", python = "^3.8"}

[tool.poetry.group.test.dependencies]
mypy = "^1.7.1"
numpy = "^1.26.2"
pytest = "^7.4.3"
pytest-asyncio = "^0.23.1"
pytest-cov = "^4.1.0"
ruff = "^0.1.6"
mypy = {version = "^1.7.1", python = "^3.8"}
pytest = {version = "^7.4.3", python = "^3.8"}
pytest-asyncio = {version = "^0.23.1", python = "^3.8"}
pytest-cov = {version = "^4.1.0", python = "^3.8"}
ruff = {version = "^0.1.6", python = "^3.8"}
numpy = {version = "^1.24", python = "^3.8"}

[build-system]
requires = ["poetry-core"]
Expand Down
6 changes: 2 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""aiomarketstack's testing package."""

import unittest

from . import test_aiomarketstack

ALL_TESTS = [
unittest.defaultTestLoader.loadTestsFromModule(test_aiomarketstack),
__all__ = [
"test_aiomarketstack",
]
6 changes: 0 additions & 6 deletions tests/__main__.py

This file was deleted.

0 comments on commit bbe6526

Please sign in to comment.