Skip to content

Commit

Permalink
Fix: wind datatype&namespace (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn authored Sep 9, 2020
1 parent 6e43c6f commit 2281eb1
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 21 deletions.
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
language_version: python3
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sudo: true

language: python

dist: xenial

python:
- "3.6"
- "3.7"
- "3.8"

install:
- pip install poetry
- poetry install

script:
- export PYTHONPATH=`pwd`; pytest tests/
- black --check --verbose .
- flake8 cy_weather_api
6 changes: 3 additions & 3 deletions cy_weather_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cyapi.client import CyAPIClient
from cyapi.models import initFromDict
from cy_weather_api.client import CyWeatherAPIClient
from cy_weather_api.models import initFromDict

__all__ = ["CyAPIClient", "initFromDict"]
__all__ = ["CyWeatherAPIClient", "initFromDict"]
3 changes: 2 additions & 1 deletion cy_weather_api/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from dataclasses import dataclass

import requests
from cyapi.models import initFromDict, CyWeatherAPIResponseHandler

from cy_weather_api.models import CyWeatherAPIResponseHandler, initFromDict

API_BASE = (
"http://api.caiyunapp.com/v2.5/{token}/{lng},{lat}/weather.json?"
Expand Down
3 changes: 1 addition & 2 deletions cy_weather_api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import orjson
from dacite import from_dict

from cyapi.models.result import cyWeatherAPIResponseResultStruct
from cy_weather_api.models.result import cyWeatherAPIResponseResultStruct


class EnhancedJSONEncoder(json.JSONEncoder):
Expand Down Expand Up @@ -69,7 +69,6 @@ def initFromDict(data: Dict) -> CyWeatherAPIResponseHandler:

if __name__ == "__main__":
import requests
# from dacite import from_dict

# NOTE: Test token, no one can ensure its availability.
TOKEN = "TAkhjf8d1nlSlspN"
Expand Down
6 changes: 3 additions & 3 deletions cy_weather_api/models/daily.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import List, Any
from typing import Any, List, Union


@dataclass
Expand All @@ -24,8 +24,8 @@ class cyWeatherAPIResponseDailyMaxMinAvgItemStruct:

@dataclass
class cyWeatherAPIResponseDailyWindItemPropertyStruct:
speed: float
direction: float
speed: Union[float, int]
direction: Union[float, int]


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions cy_weather_api/models/hourly.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from dataclasses import dataclass
from typing import Any, List
from typing import Any, List, Union


@dataclass
class cyWeatherAPIResponseHourlyWindStruct:
datetime: str
speed: float
direction: float
speed: Union[float, int]
direction: Union[float, int]


@dataclass
Expand Down
5 changes: 3 additions & 2 deletions cy_weather_api/models/realtime.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dataclasses import dataclass
from typing import Union


@dataclass
class cyWeatherAPIResponseRealtimeWindStruct:
speed: float
direction: float
speed: Union[float, int]
direction: Union[float, int]


@dataclass
Expand Down
10 changes: 5 additions & 5 deletions cy_weather_api/models/result.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass

from cyapi.models.alert import cyWeatherAPIResponseAlertStruct
from cyapi.models.hourly import cyWeatherAPIResponseHourlyStruct
from cyapi.models.minutely import cyWeatherAPIResponseMinutelyStruct
from cyapi.models.realtime import cyWeatherAPIResponseRealtimeStruct
from cyapi.models.daily import cyWeatherAPIResponseDailyStruct
from cy_weather_api.models.alert import cyWeatherAPIResponseAlertStruct
from cy_weather_api.models.daily import cyWeatherAPIResponseDailyStruct
from cy_weather_api.models.hourly import cyWeatherAPIResponseHourlyStruct
from cy_weather_api.models.minutely import cyWeatherAPIResponseMinutelyStruct
from cy_weather_api.models.realtime import cyWeatherAPIResponseRealtimeStruct


@dataclass
Expand Down
144 changes: 143 additions & 1 deletion poetry.lock

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

Loading

0 comments on commit 2281eb1

Please sign in to comment.