Skip to content

Commit 8cb7415

Browse files
committed
Clean up docstrings.
1 parent 980aba0 commit 8cb7415

11 files changed

Lines changed: 299 additions & 293 deletions

File tree

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ make update - Update pip dependencies via Poetry and export output to requir
1212
make format - Format code with Python's `Black` library.
1313
make lint - Check code formatting with `flake8`.
1414
make clean - Remove cached files and lock files.
15+
1516
endef
1617
export HELP
1718

@@ -80,8 +81,9 @@ clean:
8081
find . -name '*.log' -delete
8182
find . -name '.DS_Store' -delete
8283
find . -wholename 'logs/*.json' -delete
83-
find . -wholename '.pytest_cache' -delete
84+
find . -wholename './.pytest_cache' -delete
85+
find . -wholename './.venv' -delete
8486
find . -wholename '**/.pytest_cache' -delete
8587
find . -wholename './logs/*.json' -delete
8688
find . -wholename './logs' -delete
87-
find . -wholename '*.html' -delete
89+
find . -wholename './export/*.csv' -delete

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
![Python](https://img.shields.io/badge/Python-v^3.9-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
44
![Asyncio](https://img.shields.io/badge/Asyncio-v^3.4.3-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
5-
![Aiohttp](https://img.shields.io/badge/Aiohttp-v^3.7.4-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6-
![Aiofiles](https://img.shields.io/badge/Aiofiles-v0.7.0-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
5+
![Aiohttp](https://img.shields.io/badge/Aiohttp-v^3.8.1-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6+
![Aiofiles](https://img.shields.io/badge/Aiofiles-v^0.8.0-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
77
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
88
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/asyncio-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/issues)
99
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/asyncio-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/stargazers)

aiohttp_aiofiles_tutorial/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import aiofiles
77
from aiofiles.threadpool.text import AsyncTextIOWrapper
88
from aiohttp import ClientSession
9-
from config import FETCHED_URL_TITLES, HTML_HEADERS
9+
from config import EXPORT_FILE, HTML_HEADERS
1010
from logger import LOGGER
1111

1212
from .data import urls
@@ -17,20 +17,20 @@
1717
async def init_script():
1818
"""Initiate script by preparing an output file prior to executing tasks."""
1919
start_time = timer()
20-
async with aiofiles.open(FETCHED_URL_TITLES, mode="w+") as output_file:
21-
await output_file.write("title,url,\n")
22-
await create_and_execute_tasks(output_file)
23-
await output_file.close()
20+
async with aiofiles.open(EXPORT_FILE, mode="w+") as outfile:
21+
await outfile.write("title,url,\n")
22+
await create_and_execute_tasks(outfile)
23+
await outfile.close()
2424
LOGGER.success(f"Executed {__name__} in {time.perf_counter() - start_time:0.2f} seconds.")
2525

2626

27-
async def create_and_execute_tasks(output_file: AsyncTextIOWrapper):
27+
async def create_and_execute_tasks(outfile: AsyncTextIOWrapper):
2828
"""
2929
Open async HTTP session & execute created tasks.
3030
31-
:param AsyncTextIOWrapper output_file: Filepath to local .json file to write output to.
31+
:param AsyncTextIOWrapper outfile: Filepath of local .csv file to write to.
3232
"""
3333
async with ClientSession(headers=HTML_HEADERS) as session:
34-
task_list = await create_tasks(session, urls, output_file)
34+
task_list = await create_tasks(session, urls, outfile)
3535
inspect_event_loop()
3636
await asyncio.gather(*task_list)

aiohttp_aiofiles_tutorial/data/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Parse a predetermined CSV of URLs into a Python list."""
1+
"""Parse a local CSV into a Python list of URLs."""
22
import csv
33
from typing import List
44

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import List
2-
3-
import pytest
1+
"""Test reading tutorial sample data URLs."""
42
from aiohttp_aiofiles_tutorial.data.parser import parse_urls_from_csv
53
from config import CSV_FILEPATH
64

75

86
def test_parse_urls():
7+
"""Ensure URL sample data is parsed correctly."""
98

109
urls = parse_urls_from_csv(CSV_FILEPATH)
1110

1211
assert (type(urls)) == list
12+
assert "https://" in urls[0]

0 commit comments

Comments
 (0)