Skip to content

Commit

Permalink
*: merge classes together
Browse files Browse the repository at this point in the history
  • Loading branch information
null8626 committed Mar 5, 2024
1 parent 4b8075f commit c53c580
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 187 deletions.
4 changes: 2 additions & 2 deletions docs/client.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Client
======
Client reference
================

.. autoclass:: python_weather.client.Client
:members:
Expand Down
6 changes: 0 additions & 6 deletions docs/forecast/current_forecast.rst

This file was deleted.

3 changes: 0 additions & 3 deletions docs/forecast/daily_forecast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Daily forecast
:members:
:inherited-members:

.. autoclass:: python_weather.forecast.Astronomy()
:members:

.. autoclass:: python_weather.enums.Phase()
:members:
:undoc-members:
Expand Down
5 changes: 2 additions & 3 deletions docs/forecast/index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Forecasts
=========
Forecast reference
==================

Weather forecast-related classes used by the library to represent data returned from the API.

.. toctree::
:maxdepth: 2

weather
current_forecast
daily_forecast
hourly_forecast
9 changes: 3 additions & 6 deletions docs/forecast/weather.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
Weather forecasts
-----------------
Weather forecast
----------------

.. autoclass:: python_weather.forecast.Weather()
.. autoclass:: python_weather.forecast.Forecast()
:members:
:inherited-members:

.. autoclass:: python_weather.forecast.Area()
:members:

.. autoclass:: python_weather.enums.Kind()
:members:
:undoc-members:
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Example
.. toctree::
:maxdepth: 2
:hidden:

client
forecast/index.rst
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools"]

[project]
name = "python-weather"
version = "1.1.2"
version = "2.0.0"
description = "A free and asynchronous weather API wrapper made in Python, for Python."
readme = "README.md"
license = { text = "MIT" }
Expand Down Expand Up @@ -40,4 +40,4 @@ changes = "https://python-weather.readthedocs.io/en/latest/changelog.html"
homepage = "https://python-weather.readthedocs.io/en/latest/"
documentation = "https://python-weather.readthedocs.io/en/latest/"
repository = "https://github.com/null8626/python-weather"
download_url = "https://github.com/null8626/python-weather/archive/1.1.2.tar.gz"
download_url = "https://github.com/null8626/python-weather/archive/2.0.0.tar.gz"
4 changes: 2 additions & 2 deletions python_weather/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def humidity(self) -> int:

@property
def temperature(self) -> int:
"""The weather temperature in either Celcius or Fahrenheit."""
"""The temperature in either Celcius or Fahrenheit."""

return int(self.__inner[f'temp_{self._CustomizableBase__unit.temperature}'])

Expand Down Expand Up @@ -136,6 +136,6 @@ def description(self) -> str:

@property
def kind(self) -> Kind:
"""The kind of the weather."""
"""The kind of the forecast."""

return Kind(int(self.__inner['weatherCode']))
10 changes: 5 additions & 5 deletions python_weather/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .constants import _Unit, METRIC
from .base import CustomizableBase
from .forecast import Weather
from .forecast import Forecast
from .errors import Error
from .enums import Locale

Expand All @@ -16,7 +16,7 @@ class Client(CustomizableBase):
:param unit: Whether to use the metric or imperial/customary system (``IMPERIAL``). Defaults to ``METRIC``.
:type unit: Optional[:py:class:`enum.auto`]
:param locale: Whether to use a different locale/language as the description for the returned weather events. Defaults to ``Locale.ENGLISH``.
:param locale: Whether to use a different locale/language as the description for the returned forecst. Defaults to ``Locale.ENGLISH``.
:type locale: Optional[Locale]
:param session: Whether to use an existing aiohttp client session for requesting or not. Defaults to ``None`` (creates a new one instead)
:type session: Optional[:class:`aiohttp.ClientSession`]
Expand Down Expand Up @@ -49,7 +49,7 @@ async def get(
*,
unit: Optional[auto] = None,
locale: Optional[Locale] = None
) -> Weather:
) -> Forecast:
"""
Fetches a weather forecast for a specific location.
Expand All @@ -63,7 +63,7 @@ async def get(
:exception Error: If the aiohttp client session used by the :class:`Client` object is already closed, if the ``unit`` argument is not ``None`` and it's also not ``METRIC`` or ``IMPERIAL``, if the ``locale`` argument is not ``None`` and it's also not a part of the :class:`Locale` enum, or if the :class:`Client` cannot send a web request to the web server.
:returns: The requested weather forecast.
:rtype: Weather
:rtype: Forecast
"""

if (not isinstance(location, str)) or (not location):
Expand All @@ -89,7 +89,7 @@ async def get(
f'https://{subdomain}wttr.in/{quote_plus(location)}?format=j1'
) as resp:
try:
return Weather(await resp.json(), unit, locale)
return Forecast(await resp.json(), unit, locale)
except Exception as e:
if delay == 4:
raise e # okay, that's too much requests - just raise the error
Expand Down
Loading

0 comments on commit c53c580

Please sign in to comment.