Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f481e7

Browse files
committedOct 7, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5937a0a commit 8f481e7

File tree

7 files changed

+65
-39
lines changed

7 files changed

+65
-39
lines changed
 

‎LICENSE

-3
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

+2-2
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

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
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 = max.jahn45@gmail.com
99
license = MIT
10-
license_file = LICENSE
10+
license_files = LICENSE
1111
platforms = any
1212
classifiers =
1313
Development Status :: 3 - Alpha
1414
License :: OSI Approved :: MIT License
1515
Operating System :: OS Independent
1616
Programming Language :: Python :: 3
1717
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
2218
project_urls =
2319
Changelog = https://github.com/pytask-dev/pytask-vscode/blob/main/CHANGES.rst
2420
Documentation = https://github.com/pytask-dev/pytask-vscode
@@ -31,7 +27,7 @@ install_requires =
3127
click
3228
pytask>=0.4.2
3329
requests
34-
python_requires = >=3.7
30+
python_requires = >=3.8
3531
include_package_data = True
3632
package_dir = =src
3733
zip_safe = False

‎src/pytask_vscode/__init__.py

+1
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

+52-23
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

+6-3
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

+1-1
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)
Please sign in to comment.