Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update async_timeout and drop loop argument #12

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pydelijn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""Initialize the package."""
NAME = "pydelijn"

__version__ = "1.0.0"
7 changes: 3 additions & 4 deletions pydelijn/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ class Passages:
"""A class to get passage information."""

def __init__(
self, loop, stopid, maxpassages, subscriptionkey, session=None, utcoutput=None
self, stopid, maxpassages, subscriptionkey, session=None, utcoutput=None
):
"""Initialize the class."""
self.loop = loop
self.session = session
self.stopid = str(stopid)
self.stopname = self.stopid
Expand All @@ -54,7 +53,7 @@ async def get_stopname(self):
endpointstop = "{}haltes/{}/{}".format(
BASE_URL, str(entitynum), str(self.stopid)
)
common = CommonFunctions(self.loop, self.session, self.subscriptionkey)
common = CommonFunctions(self.session, self.subscriptionkey)
resultstop = await common.api_call(endpointstop)
if resultstop is not None:
self.stopname = "{}, {}".format(
Expand Down Expand Up @@ -105,7 +104,7 @@ async def get_passages(self):
if self.session is None:
selfcreatedsession = True
entitynum = self.stopid[:1]
common = CommonFunctions(self.loop, self.session, self.subscriptionkey)
common = CommonFunctions(self.session, self.subscriptionkey)
passages = []
tzone = pytz.timezone("Europe/Brussels")

Expand Down
5 changes: 2 additions & 3 deletions pydelijn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
class CommonFunctions:
"""A class for common functions."""

def __init__(self, loop, session, subscriptionkey):
def __init__(self, session, subscriptionkey):
"""Initialize the class."""
self.loop = loop
self.session = session
self.subscriptionkey = subscriptionkey

Expand All @@ -24,7 +23,7 @@ async def api_call(self, endpoint):
if self.session is None:
self.session = aiohttp.ClientSession()
try:
async with async_timeout.timeout(5, loop=self.loop):
async with async_timeout.timeout(5):
LOGGER.debug("Endpoint URL: %s", str(endpoint))
response = await self.session.get(url=endpoint, headers=headers)
if response.status == 200:
Expand Down
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
"""Setup tools config."""
import re

import setuptools

with open("README.md", "r") as fh:
LONG = fh.read()

with open("pydelijn/__init__.py", "r") as fd:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE
).group(1)

setuptools.setup(
name="pydelijn",
version="0.6.1",
version=version,
author="bollewolle",
author_email="dev@bollewolle.be",
python_requires=">=3.5.0",
Expand All @@ -18,7 +25,7 @@
packages=setuptools.find_packages(exclude=('tests',)),
install_requires=[
'aiohttp>=3.6.2,<4.0',
'async_timeout>=3.0.1,<4.0',
'async_timeout>=4.0.0,<5.0',
'pytz>=2020.1'
],
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def test_pydelijn():
maxpassages = 10
custom_session = aiohttp.ClientSession()
delijndata = Passages(
LOOP, stopid, maxpassages, subscriptionkey, custom_session, True
stopid, maxpassages, subscriptionkey, custom_session, True
)
await delijndata.get_passages()
print_data(delijndata)
Expand Down