Skip to content

[pre-commit.ci] pre-commit autoupdate #1

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ['--maxkb=100']
Expand All @@ -16,7 +16,7 @@ repos:
args: [--branch, main]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
Expand All @@ -25,42 +25,42 @@ repos:
- id: python-use-type-annotations
- id: text-unicode-replacement-char

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.15.0
hooks:
- id: reorder-python-imports
args: [--py37-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
rev: v2.8.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 25.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
rev: v1.7.7
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.241
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.3
hooks:
- id: ruff
- repo: https://github.com/dosisod/refurb
rev: v1.9.1
rev: v2.1.0
hooks:
- id: refurb
args: [--ignore, FURB126]

- repo: https://github.com/econchick/interrogate
rev: 1.5.0
rev: 1.7.0
hooks:
- id: interrogate
args: [-v, --fail-under=75]
exclude: ^(tests/)
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.22
hooks:
- id: mdformat
additional_dependencies: [
Expand All @@ -85,7 +85,7 @@ repos:
# path/to/file.py
# )$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.991'
rev: 'v1.16.1'
hooks:
- id: mypy
args: [
Expand All @@ -94,11 +94,11 @@ repos:
]
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.4.1
hooks:
- id: codespell
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
rev: "0.50"
hooks:
- id: check-manifest
args: [--no-build-isolation]
Expand Down
3 changes: 0 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.



4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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


## Installation

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

```console
$ pip install pytask-vscode
Expand Down
11 changes: 3 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
[metadata]
name = pytask-vscode
name = pytask_vscode
description = Additional Logging for VS Code integration
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/pytask-dev/pytask-vscode
author = Max Jahn
author_email = [email protected]
license = MIT
license_file = LICENSE
license_files = LICENSE
platforms = any
classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
project_urls =
Changelog = https://github.com/pytask-dev/pytask-vscode/blob/main/CHANGES.rst
Documentation = https://github.com/pytask-dev/pytask-vscode
Expand All @@ -31,7 +26,7 @@ install_requires =
click
pytask>=0.4.2
requests
python_requires = >=3.7
python_requires = >=3.9
include_package_data = True
package_dir = =src
zip_safe = False
Expand Down
1 change: 1 addition & 0 deletions src/pytask_vscode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the main namespace of the package."""

from __future__ import annotations

try:
Expand Down
75 changes: 52 additions & 23 deletions src/pytask_vscode/execution.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,67 @@
from __future__ import annotations


import pytask
import json
import requests
from contextlib import redirect_stdout
import io


@pytask.hookimpl(tryfirst=True)
def pytask_collect_log(session: pytask.Session, reports: list[pytask.CollectionReport], tasks: list[pytask.PTask]) -> None:
try:
if session.config['command'] == 'collect':
exitcode = 0
for report in reports:
if report.outcome == pytask.CollectionOutcome.FAIL:
exitcode = 3
result = [{'name' : task.name.split('/')[-1], 'path' : str(task.path)} if isinstance(task,pytask.PTaskWithPath) else {'name' : task.name, 'path' : ''} for task in tasks]
res = requests.post('http://localhost:6000/pytask', json={"exitcode" : exitcode, "tasks": result}, timeout=0.0001)
except requests.exceptions.ReadTimeout:
pass
except Exception as e:
pass
def pytask_collect_log(
session: pytask.Session,
reports: list[pytask.CollectionReport],
tasks: list[pytask.PTask],
) -> None:
try:
if session.config["command"] == "collect":
exitcode = 0
for report in reports:
if report.outcome == pytask.CollectionOutcome.FAIL:
exitcode = 3
result = [
(
{"name": task.name.split("/")[-1], "path": str(task.path)}
if isinstance(task, pytask.PTaskWithPath)
else {"name": task.name, "path": ""}
)
for task in tasks
]
res = requests.post(
"http://localhost:6000/pytask",
json={"exitcode": exitcode, "tasks": result},
timeout=0.0001,
)
except requests.exceptions.ReadTimeout:
pass
except Exception:
pass


@pytask.hookimpl(tryfirst=True)
def pytask_execute_task_log_end(session: pytask.Session, report: pytask.ExecutionReport) -> None:

def pytask_execute_task_log_end(
session: pytask.Session, report: pytask.ExecutionReport
) -> None:

try:
if report.outcome == pytask.TaskOutcome.FAIL:
with pytask.console.capture() as capture:
pytask.console.print(pytask.Traceback(report.exc_info))
s = capture.get()
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome), 'exc_info' : s}
result = {
"type": "task",
"name": report.task.name.split("/")[-1],
"outcome": str(report.outcome),
"exc_info": s,
}
else:
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome)}
res = requests.post('http://localhost:6000/pytask', json=result, timeout=0.00001)
except requests.exceptions.ReadTimeout:
result = {
"type": "task",
"name": report.task.name.split("/")[-1],
"outcome": str(report.outcome),
}
res = requests.post(
"http://localhost:6000/pytask", json=result, timeout=0.00001
)
except requests.exceptions.ReadTimeout:
pass
except Exception as e:#
except Exception:
pass
9 changes: 6 additions & 3 deletions src/pytask_vscode/plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

import pytask
from pytask_vscode import execution
from pluggy import PluginManager
from pytask_vscode import execution


@pytask.hookimpl
def pytask_add_hooks(pm : PluginManager) -> None:
pm.register(execution)
def pytask_add_hooks(pm: PluginManager) -> None:
pm.register(execution)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from click.testing import CliRunner


@pytest.fixture()
@pytest.fixture
def runner():
return CliRunner()