Skip to content

Commit 9556d90

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 34fa276 commit 9556d90

File tree

7 files changed

+65
-40
lines changed

7 files changed

+65
-40
lines changed

LICENSE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,3 @@ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1919
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
2020
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2121
OTHER DEALINGS IN THE SOFTWARE.
22-
23-
24-

README.md

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

33
This is a plugin for Pytask. It is needed to use the Pytask VS Code Extension.
44

5-
65
## Installation
76

8-
pytask-vscode is available on [PyPI](https://pypi.org/project/pytask-vscode/). Install it with
7+
pytask-vscode is available on [PyPI](https://pypi.org/project/pytask-vscode/). Install
8+
it with
99

1010
```console
1111
$ pip install pytask-vscode

setup.cfg

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
[metadata]
2-
name = pytask-vscode
2+
name = pytask_vscode
33
description = Additional Logging for VS Code integration
44
long_description = file: README.md
55
long_description_content_type = text/markdown
66
url = https://github.com/pytask-dev/pytask-vscode
77
author = Max Jahn
88
author_email = [email protected]
99
license = MIT
10-
license_file = LICENSE
10+
license_files = LICENSE
1111
platforms = any
1212
classifiers =
1313
Development Status :: 3 - Alpha
14-
License :: OSI Approved :: MIT License
1514
Operating System :: OS Independent
1615
Programming Language :: Python :: 3
1716
Programming Language :: Python :: 3 :: Only
18-
Programming Language :: Python :: 3.7
19-
Programming Language :: Python :: 3.8
20-
Programming Language :: Python :: 3.9
21-
Programming Language :: Python :: 3.10
2217
project_urls =
2318
Changelog = https://github.com/pytask-dev/pytask-vscode/blob/main/CHANGES.rst
2419
Documentation = https://github.com/pytask-dev/pytask-vscode
@@ -31,7 +26,7 @@ install_requires =
3126
click
3227
pytask>=0.4.2
3328
requests
34-
python_requires = >=3.7
29+
python_requires = >=3.9
3530
include_package_data = True
3631
package_dir = =src
3732
zip_safe = False

src/pytask_vscode/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module contains the main namespace of the package."""
2+
23
from __future__ import annotations
34

45
try:

src/pytask_vscode/execution.py

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,67 @@
1+
from __future__ import annotations
2+
3+
14
import pytask
2-
import json
35
import requests
4-
from contextlib import redirect_stdout
5-
import io
6+
67

78
@pytask.hookimpl(tryfirst=True)
8-
def pytask_collect_log(session: pytask.Session, reports: list[pytask.CollectionReport], tasks: list[pytask.PTask]) -> None:
9-
try:
10-
if session.config['command'] == 'collect':
11-
exitcode = 0
12-
for report in reports:
13-
if report.outcome == pytask.CollectionOutcome.FAIL:
14-
exitcode = 3
15-
result = [{'name' : task.name.split('/')[-1], 'path' : str(task.path)} if isinstance(task,pytask.PTaskWithPath) else {'name' : task.name, 'path' : ''} for task in tasks]
16-
res = requests.post('http://localhost:6000/pytask', json={"exitcode" : exitcode, "tasks": result}, timeout=0.0001)
17-
except requests.exceptions.ReadTimeout:
18-
pass
19-
except Exception as e:
20-
pass
9+
def pytask_collect_log(
10+
session: pytask.Session,
11+
reports: list[pytask.CollectionReport],
12+
tasks: list[pytask.PTask],
13+
) -> None:
14+
try:
15+
if session.config["command"] == "collect":
16+
exitcode = 0
17+
for report in reports:
18+
if report.outcome == pytask.CollectionOutcome.FAIL:
19+
exitcode = 3
20+
result = [
21+
(
22+
{"name": task.name.split("/")[-1], "path": str(task.path)}
23+
if isinstance(task, pytask.PTaskWithPath)
24+
else {"name": task.name, "path": ""}
25+
)
26+
for task in tasks
27+
]
28+
res = requests.post(
29+
"http://localhost:6000/pytask",
30+
json={"exitcode": exitcode, "tasks": result},
31+
timeout=0.0001,
32+
)
33+
except requests.exceptions.ReadTimeout:
34+
pass
35+
except Exception:
36+
pass
2137

2238

2339
@pytask.hookimpl(tryfirst=True)
24-
def pytask_execute_task_log_end(session: pytask.Session, report: pytask.ExecutionReport) -> None:
25-
40+
def pytask_execute_task_log_end(
41+
session: pytask.Session, report: pytask.ExecutionReport
42+
) -> None:
43+
2644
try:
2745
if report.outcome == pytask.TaskOutcome.FAIL:
2846
with pytask.console.capture() as capture:
2947
pytask.console.print(pytask.Traceback(report.exc_info))
3048
s = capture.get()
31-
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome), 'exc_info' : s}
49+
result = {
50+
"type": "task",
51+
"name": report.task.name.split("/")[-1],
52+
"outcome": str(report.outcome),
53+
"exc_info": s,
54+
}
3255
else:
33-
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome)}
34-
res = requests.post('http://localhost:6000/pytask', json=result, timeout=0.00001)
35-
except requests.exceptions.ReadTimeout:
56+
result = {
57+
"type": "task",
58+
"name": report.task.name.split("/")[-1],
59+
"outcome": str(report.outcome),
60+
}
61+
res = requests.post(
62+
"http://localhost:6000/pytask", json=result, timeout=0.00001
63+
)
64+
except requests.exceptions.ReadTimeout:
3665
pass
37-
except Exception as e:#
66+
except Exception:
3867
pass

src/pytask_vscode/plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import annotations
2+
13
import pytask
2-
from pytask_vscode import execution
34
from pluggy import PluginManager
5+
from pytask_vscode import execution
6+
47

58
@pytask.hookimpl
6-
def pytask_add_hooks(pm : PluginManager) -> None:
7-
pm.register(execution)
9+
def pytask_add_hooks(pm: PluginManager) -> None:
10+
pm.register(execution)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
from click.testing import CliRunner
55

66

7-
@pytest.fixture()
7+
@pytest.fixture
88
def runner():
99
return CliRunner()

0 commit comments

Comments
 (0)