Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adopt pre-commit-ci for linting and typecheck #364

Merged
merged 7 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
achimnol marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
- id: mypy
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@ Apache License
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Now from separate terminal it is possible to connect to the application::
or the included python client::

$ python -m aiomonitor.cli


Tutorial
--------

Expand Down Expand Up @@ -122,9 +122,9 @@ Now you can type commands, for instance, ``help``::

monitor >>> help
Usage: help [OPTIONS] COMMAND [ARGS]...

To see the usage of each command, run them with "--help" option.

Commands:
cancel Cancel an indicated task
console Switch to async Python REPL
Expand Down
4 changes: 2 additions & 2 deletions aiomonitor/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def _trace_termination(self, _: "asyncio.Task[Any]") -> None:
self_id,
name=self.get_name(),
coro=_format_coroutine(self._orig_coro).partition(" ")[0],
cancelled=self.cancelled(),
exc_repr=exc_repr,
started_at=self._started_at,
terminated_at=time.perf_counter(),
cancelled=self.cancelled(),
termination_stack=self._termination_stack,
canceller_stack=None,
exc_repr=exc_repr,
persistent=self._persistent,
)
self._termination_info_queue.put_nowait(task_info)
Expand Down
9 changes: 4 additions & 5 deletions aiomonitor/types.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import traceback
from dataclasses import dataclass
from typing import List, Optional

from attrs import define


@define
@dataclass
class TerminatedTaskInfo:
id: str
name: str
coro: str
started_at: float
terminated_at: float
cancelled: bool
termination_stack: Optional[List[traceback.FrameSummary]]
termination_stack: Optional[List[traceback.FrameSummary]] = None
canceller_stack: Optional[List[traceback.FrameSummary]] = None
exc_repr: Optional[str] = None
persistent: bool = False


@define
@dataclass
class CancellationChain:
target_id: str
canceller_id: str
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 0 additions & 1 deletion tests/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def console_enabled(request):

@pytest.mark.asyncio
async def test_ctor(event_loop, unused_port, console_enabled):

with Monitor(event_loop, console_enabled=console_enabled):
await asyncio.sleep(0.01)
with start_monitor(event_loop, console_enabled=console_enabled) as m:
Expand Down