Skip to content

Commit 902ce1f

Browse files
committed
Add a web attribute to ctx which can be used to make web requests.
Fixes #19 Signed-off-by: Pedro Algarvio <[email protected]>
1 parent f9c1548 commit 902ce1f

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,5 @@ repos:
113113
additional_dependencies:
114114
- types-attrs
115115
- types-setuptools
116+
- types-requests
116117
# <---- Code Analysis --------------------------------------------------------------------------

changelog/19.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The `ctx` now has a `web` attribute, a `requests.Session` instance which can be used to make web requests.

requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
attrs
22
rich
3+
requests >= 2.28.2
34
typing-extensions; python_version < "3.11"

src/ptscripts/parser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from typing import TYPE_CHECKING
2222
from typing import TypedDict
2323

24+
import requests
2425
import rich
2526
from rich.console import Console
2627
from rich.theme import Theme
@@ -232,6 +233,13 @@ def virtualenv(
232233
) as venv:
233234
yield venv
234235

236+
@property
237+
def web(self) -> requests.Session:
238+
"""
239+
Returns an instance of :py:class:`~requests.Session`.
240+
"""
241+
return requests.Session()
242+
235243

236244
class Parser:
237245
"""

0 commit comments

Comments
 (0)