profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/Timmmm/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

Timmmm/autorebase 61

Automatically rebase all your branches onto master

Timmmm/adaptagrams 0

Libraries for constraint-based layout and connector routing for diagrams.

Timmmm/angular_components 0

The official Material Design components for AngularDart. Used at Google in production apps.

Timmmm/arcanist 0

Command line interface for Phabricator

Timmmm/arcanist-linters 0

A collection of custom Arcanist linters

Timmmm/Arduino 0

open-source electronics prototyping platform

Timmmm/ARDUTEX 0

ARDUTEX TRAILING EDGE MOSFET AC LIGHT DIMMER

Timmmm/arrayfire-rust 0

Rust wrapper for ArrayFire

Timmmm/awesome-electronics 0

A curated list of awesome resources for electronic engineers and hobbyists

Timmmm/awesome-rust 0

A curated list of Rust code and resources.

issue openedManimCommunity/manim

Multiple scenes are saved to the same file.

Description of bug / unexpected behavior

If you have multiple scenes they all get saved to the same file. Very similar to #1578.

main.py

from manim import *

config.background_color = "#333388"
config.frame_width = 40
config.scene_names = ["A", "B"]

class A(Scene):
    def construct(self):
        a = Circle(5)
        self.play(Create(a))

class B(Scene):
    def construct(self):
        a = Circle(5)
        self.play(Create(a))

manim.cfg

[CLI]
frame_rate = 30
pixel_height = 1080
pixel_width = 1920

Logs

<details><summary>Terminal output</summary>

Uhm... -v DEBUG does not work:

manim -v DEBUG render main.py
Manim Community v0.10.0

Traceback (most recent call last):
  File "/usr/local/bin/manim", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/manim/cli/render/commands.py", line 132, in render
    for SceneClass in scene_classes_from_file(file):
  File "/usr/local/lib/python3.9/site-packages/manim/utils/module_ops.py", line 124, in scene_classes_from_file
    module = get_module(file_path)
  File "/usr/local/lib/python3.9/site-packages/manim/utils/module_ops.py", line 51, in get_module
    raise FileNotFoundError(f"{file_name} not found")
FileNotFoundError: render not found

Here's the output without that:

manim render main.py 
Manim Community v0.10.0

[09/24/21 20:12:03] INFO     Animation 0 : Using cached data (hash : 2103384290_1959254436_1145583325)                                                      cairo_renderer.py:107
                    INFO                                                                                                                                 scene_file_writer.py:606
                             File ready at '/.../project/media/videos/main/1080p60/A.mp4'                                                         
                                                                                                                                                                                 
                    INFO     Rendered A                                                                                                                              scene.py:233
                             Played 1 animations                                                                                                                                 
                    INFO     Animation 0 : Using cached data (hash : 2103384290_950503052_1145583325)                                                       cairo_renderer.py:107
                    INFO                                                                                                                                 scene_file_writer.py:606
                             File ready at '/.../project/media/videos/main/1080p60/A.mp4'                                                         
                                                                                                                                                                                 
                    INFO     Rendered B                                                                                                                              scene.py:233
                             Played 1 animations                                                                                                                                 

</details>

System specifications

<details><summary>System Details</summary>

  • OS: Mac
  • Python version: 3.9.7

</details>

created time in a day

issue commentManimCommunity/manim

Ability to set the default font

Yeah eek. It seems like some things like Integer don't even let you set the font anyway. Thanks for the suggestion though!

Timmmm

comment created time in a day

issue commentManimCommunity/manim

Ability to set the default font

Yeah unfortunately that still means I have to go around changing every Text. Thanks for the link to the PR though - I'll check it out.

Timmmm

comment created time in a day

issue openedManimCommunity/manim

Ability to set the default font

It should be possible to set a global default font, rather than having to explicitly set it in every Text object.

If that is already possible somehow then it should be documented, because I could figure it out even after reading the source code.

created time in a day

issue closedmicrosoft/pyright

Lambda capture types are unnecessarily conservative

Consider the following code:

def foo(x: Optional[int]) -> int:
    if x is None:
        x = 5
    c = lambda: x
    return c()

Pyright gives an error on the last line, because x in the lambda is inferred to be int | None. But at the point where c is defined, and x is captured, Pyright has already narrowed x to just int.

Shouldn't the lambda captures take the types of the variables they capture from the point where they are defined, including narrowing? Or am I missing some devious Python behaviour that makes this not safe?

closed time in 2 days

Timmmm

issue commentmicrosoft/pyright

Lambda capture types are unnecessarily conservative

Ah of course! Thanks!

Timmmm

comment created time in 2 days

issue openedmicrosoft/pyright

Lambda capture types are unnecessarily conservative

Consider the following code:

def foo(x: Optional[int]) -> int:
    if x is None:
        x = 5
    c = lambda: x
    return c()

Pyright gives an error on the last line, because x in the lambda is inferred to be int | None. But at the point where c is defined, and x is captured, Pyright has already narrowed x to just int.

Shouldn't the lambda captures take the types of the variables they capture from the point where they are defined, including narrowing? Or am I missing some devious Python behaviour that makes this not safe?

created time in 2 days

issue openedmicrosoft/pyright

Type Foo cannot be assigned to type Foo

With the following code:

class Ob:
    subobjects: list[Ob]

    def split(self) -> list[Ob]:
        result = [self] if len(self.subobjects) > 1 else []
        return result + self.subobjects

I get this rather confusing error for the last line:

Expression of type "list[Ob]" cannot be assigned to return type "list[Ob]"
  TypeVar "_T@list" is invariant
    Type "Ob" cannot be assigned to type "Ob"
(variable) subobjects: list[Ob]

If you hover result it tells you the inferred type is list[Ob], however if you explicitly add that

        result: list[Ob] = [self] if len(self.subobjects) > 1 else []

then the error goes away. Seems like there is more to the type than what is printed.

Found via Pylance v2021.9.3.

created time in 2 days

issue commentrust-lang/rust

Please reconsider endorsing `dirs` and deprecating `std::env::home_dir`

Yes it would be nice if the final solution provides all the directories that dirs did but it's ridiculous to assert that there are no use cases for getting the home directory.

Xaeroxe

comment created time in 2 days

issue commentmicrosoft/debugpy

Listen on any port

Ah nice, thanks!

Timmmm

comment created time in 2 days

push eventTimmmm/manual

Tim Hutt

commit sha 8c9ca870581044bdac10d182122c2a0047dfb5f0

Format

view details

push time in 2 days

issue openedmicrosoft/debugpy

Listen on a any port

Would it be possible to make it so that you can tell debugpy to listen on any port and then return the port? This is to support multiple people debugging on the same machine which is pretty awkward otherwise.

created time in 2 days

PR opened denoland/manual

Update permissions.md
  • Fix typo
  • A couple of clarifications
  • Change cat to whoami which is available on Windows, Mac and Linux. On the downside I had to remove the argument so I added an explicit note about that.
  • Remove problematic allow-list. It would be better with "whitelist" but was able to make it flow much better anyway using other normal words.
+18 -17

0 comment

1 changed file

pr created time in 2 days

push eventTimmmm/manual

Tim

commit sha 00caa29423436bd2eeb95ff8913ebeba1d8a477f

Update permissions.md * Fix typo * A couple of clarifications * Change `cat` to `whoami` which is available on Windows, Mac and Linux. On the downside I had to remove the argument so I added an explicit note about that. * Remove problematic `allow-list`. It would be better with "whitelist" but was able to make it flow much better anyway using other normal words.

view details

push time in 2 days

fork Timmmm/manual

Deno's documentation

https://deno.land/manual

fork in 3 days

pull request commentManimCommunity/manim

Make colour aliases IDE-friendly

Maybe I'm missing something but why does this still say Review required but GameDungion has approved it?

Timmmm

comment created time in 3 days

push eventTimmmm/manim

icedcoffeeee

commit sha 268da5045a7691f596327a80ba8a3ed31ed862be

Deprecated redundant methods of Mobject (#2024) * deprecated redundants * remove usage of redundants * added deprecation period * added replacement argument Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added deprecation arguments * changes occurrences Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Darylgolden <darylgolden@gmail.com>

view details

Ryan McCauley

commit sha 5f641ecf6d52aadb113e87f749275fa3e9413e8e

Fix opengl overriding svg fill color (#2028) Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>

view details

Ryan McCauley

commit sha 32eda9d66a5d2fcb23b28cc4e9ffd7a54f8e7b0f

Add config to enable opengl wireframe (#2041)

view details

Ryan McCauley

commit sha 3b55ea5e9e0e218f4c5c9e2333cfa2b4bfd9ce38

Fixed opengl shift animation for :class:~.Text (#2026) * use all families for transforms * Only use families for opengl Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com>

view details

Hugues Devimeux

commit sha 3e3770846a6866f7b0fed15acccafbe75ec42924

Fixed issue related to the logger (#2066)

view details

pre-commit-ci[bot]

commit sha f42e9c82715ff140ed7613d6c4f8728f65880d47

[pre-commit.ci] pre-commit autoupdate (#2067) updates: - [github.com/psf/black: 21.8b0 → 21.9b0](https://github.com/psf/black/compare/21.8b0...21.9b0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

view details

Ryan McCauley

commit sha 4c73fa235524c053d7e48339a56e4a5aefae4235

Added opengl compatibility for :meth:`~Cylinder.add_bases`.(#2039) Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com>

view details

Ryan McCauley

commit sha 785b5405990435b8e3c8640886c1b63a283415eb

Add OpenGL support for :class:`~.StreamLines` (#1971) * Add opengl support for vector_field * Add background image method * did I commit anything? * migrate methods * migrate methods * Streamlines opengl support * cleanup * Use passed stroke width * Pass colors and opacity * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update manim/mobject/vector_field.py Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update manim/mobject/vector_field.py Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add docstrings to gradient method * Use VMobject and OpenGLVMobject for line * Remove duplicate set_rgba_array_direct method Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

view details

Ryan McCauley

commit sha 76b3e169d6f3cce10ca3a4719e719d34839815a0

Return self from triangulation wrapper (#2037)

view details

Ryan McCauley

commit sha 977320d51bd06a6faac6d2cec42b47d553508bab

Remove unused set_opacity method (#2060)

view details

Tim

commit sha 81f2710105852e19d30e202dc0328fa13928bb8d

Merge branch 'main' into patch-1

view details

push time in 3 days

issue commentprettier/prettier

Prettier adding newline before closing bracket, only on certain elements (e.g. Label)

That's not a good reason really.

It's an extremely good reason. An auto-formatter should not change the behaviour of code by default. That would be insane.

You can opt in to the risky but pretty behaviour if you prefer it.

toddhd

comment created time in 7 days

issue commentprettier/prettier

Prettier adding newline before closing bracket, only on certain elements (e.g. Label)

The reason is because in general whitespace in elements is significant, so Prettier does the safe thing and preserves it. That help text should say "significant" where it says "sensitive".

The CSS option tries to figure out cases where it actually isn't significant, but it can't really do it 100% reliably - that would be impossible.

toddhd

comment created time in 8 days

pull request commentManimCommunity/manim

Make colour aliases IDE-friendly

Yeah 100% agree about animate. Hopefully we can just add manual type annotations for those magically generated methods.

Timmmm

comment created time in 8 days

issue commentManimCommunity/manim

Table.get_entries() should be split in two

Yeah that would be a good intermediate step. Still worth changing get_entries() at some point I think so that people who use Python with proper static types don't have to do type assertions.

Timmmm

comment created time in 9 days

issue openedManimCommunity/manim

Table.get_entries() should be split in two

Currently there is this method:

    def get_entries(
        self, pos: Optional[Sequence[int]] = None
    ) -> Union[VMobject, VGroup]:
        """Return the individual entries of the table (including labels) or one specific entry
        if the parameter, ``pos``,  is set.

It would be much better if this were two separate functions:

    def get_entries(self) -> VGroup:
        ...

    def get_entry(self, pos:Sequence[int]) -> VMobject:
        ...

More obvious what is happening, simpler, you don't have the weirdness of get_entries returning a single entry, and it makes the return type explicit.

The code even makes it obvious that this is really two methods merged into one:

        if pos is not None:
            # One method here.
            if (
                self.row_labels is not None
                and self.col_labels is not None
                and self.top_left_entry is None
            ):
                index = len(self.mob_table[0]) * (pos[0] - 1) + pos[1] - 2
                return self.elements[index]
            else:
                index = len(self.mob_table[0]) * (pos[0] - 1) + pos[1] - 1
                return self.elements[index]
        else:
            # A completely different one here.
            return self.elements

Same for get_entries_without_labels.

I assume since you're still at version 0.10 breaking changes are allowed?

created time in 10 days

issue commentManimCommunity/manim

Setting frame width and frame heigh is only taking frame_width into account.

Yeah I think I'm seeing the same problem. frame_height is just completely ignored.

Actually I investigated and that is the case. By default frame_height is ignored and the camera resizes maintaining aspect ratio and using frame_width to set the size.

See the code here.

It would be great if this were documented, particularly because all of the config examples use frame_height not frame_width!!

I also suggest the behaviour should change to this:

if frame_height is not None and frame_width is not None:
  resize(frame_width, frame_height)
elif frame_height is not None:
  resize(<preserve AR>, frame_height)
elif frame_width is not None:
  resize(frame_width, <preserve AR>)
else:
  default size
kolibril13

comment created time in 10 days

PR opened ManimCommunity/manim

Make colour aliases IDE-friendly

Fixes #2049

<!-- Thank you for contributing to Manim! Learn more about the process in our contributing guidelines: https://docs.manim.community/en/latest/contributing.html -->

Overview: What does this pull request change?

<!-- If there is more information than the PR title that should be added to our release changelog, add it in the following changelog section. This is optional, but recommended for larger pull requests. -->

Makes colour aliases like BLUE more tool friendly (e.g. in VSCode).

<!--changelog-start-->

<!--changelog-end-->

Motivation and Explanation: Why and how do your changes improve the library?

<!-- Optional for bugfixes, small enhancements, and documentation-related PRs. Otherwise, please give a short reasoning for your changes. -->

See #2049

Links to added or changed documentation pages

<!-- Please add links to the affected documentation pages (edit the description after opening the PR). The link to the documentation for your PR is https://manimce--####.org.readthedocs.build/en/####/, where #### represents the PR number. -->

Further Information and Comments

<!-- If applicable, put further comments for the reviewers here. -->

No idea why the grey order was A, B, C, E, D in the old code lol.

<!-- Thank you again for contributing! Do not modify the lines below, they are for reviewers. -->

Reviewer Checklist

  • [x] The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • [ ] If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • [ ] If applicable: newly added functions and classes are tested
+107 -20

0 comment

1 changed file

pr created time in 10 days

push eventTimmmm/manim

Tim

commit sha 5fe698032323f270cdfe7e3f2c3b3fd7f320c31c

Make colour aliases IDE-friendly Fixes #2049

view details

push time in 10 days

fork Timmmm/manim

A community-maintained Python framework for creating mathematical animations.

https://www.manim.community

fork in 10 days

issue openedManimCommunity/manim

Colour constants are not tool friendly.

In color.py you have this code:

class Colors(Enum):
    white = "#FFFFFF"
    gray_a = "#DDDDDD"
    gray_b = "#BBBBBB"
   ...

# Create constants from Colors enum
constants_names = []
for name, value in Colors.__members__.items():
    name = name.upper()
    value = value.value
    constants_names.append(name)
    locals()[name] = value
    if "GRAY" in name:
        name = name.replace("GRAY", "GREY")
        locals()[name] = value
        constants_names.append(name)

__all__ += ...
    "WHITE",
    "GRAY_A",
    "GREY_A",
...

This is unfortunate because it means tools like IDEs, type checkers etc. do not know about WHITE, BLUE and so on.

There has been an attempt to make this work:

# Add constants to module exports. Simply adding constants_names would work fine, but
# would make it hard for IDEs to understand that colors are exported. Therefore the
# result of the following print statement is added instead.

Unfortunately it doesn't work with VSCode / Pyright. Given that you're already using codegen, we may as well just do it properly.

def print_constant_definitions():
    """
    A simple function used to generate the constant values below. To run it
    paste this function and the Colors class into a file and run them.
    """
    constants_names: list[str] = []
    for name in Colors.__members__.keys():
        name_upper = name.upper()

        constants_names.append(name_upper)
        print(f"{name_upper} = Colors.{name}")

        if "GRAY" in name_upper:
            name_upper = name_upper.replace("GRAY", "GREY")

            constants_names.append(name_upper)
            print(f"{name_upper} = Colors.{name}")

    constants_names_repr = "[\n    \"" + "\",\n    \"".join(constants_names) + "\",\n]"

    print(f"\n__all__ += {constants_names_repr}")


WHITE = "#FFFFFF"
GRAY_A = "#DDDDDD"
GREY_A = "#DDDDDD"
GRAY_B = "#BBBBBB"
GREY_B = "#BBBBBB"
GRAY_C = "#888888"
GREY_C = "#888888"
GRAY_D = "#444444"
GREY_D = "#444444"
GRAY_E = "#222222"
GREY_E = "#222222"
BLACK = "#000000"
LIGHTER_GRAY = "#DDDDDD"
LIGHTER_GREY = "#DDDDDD"
LIGHT_GRAY = "#BBBBBB"
LIGHT_GREY = "#BBBBBB"
GRAY = "#888888"
GREY = "#888888"
DARK_GRAY = "#444444"
DARK_GREY = "#444444"
DARKER_GRAY = "#222222"
DARKER_GREY = "#222222"
BLUE_A = "#C7E9F1"
BLUE_B = "#9CDCEB"
BLUE_C = "#58C4DD"
BLUE_D = "#29ABCA"
BLUE_E = "#236B8E"
PURE_BLUE = "#0000FF"
BLUE = "#58C4DD"
DARK_BLUE = "#236B8E"
TEAL_A = "#ACEAD7"
TEAL_B = "#76DDC0"
TEAL_C = "#5CD0B3"
TEAL_D = "#55C1A7"
TEAL_E = "#49A88F"
TEAL = "#5CD0B3"
GREEN_A = "#C9E2AE"
GREEN_B = "#A6CF8C"
GREEN_C = "#83C167"
GREEN_D = "#77B05D"
GREEN_E = "#699C52"
PURE_GREEN = "#00FF00"
GREEN = "#83C167"
YELLOW_A = "#FFF1B6"
YELLOW_B = "#FFEA94"
YELLOW_C = "#FFFF00"
YELLOW_D = "#F4D345"
YELLOW_E = "#E8C11C"
YELLOW = "#FFFF00"
GOLD_A = "#F7C797"
GOLD_B = "#F9B775"
GOLD_C = "#F0AC5F"
GOLD_D = "#E1A158"
GOLD_E = "#C78D46"
GOLD = "#F0AC5F"
RED_A = "#F7A1A3"
RED_B = "#FF8080"
RED_C = "#FC6255"
RED_D = "#E65A4C"
RED_E = "#CF5044"
PURE_RED = "#FF0000"
RED = "#FC6255"
MAROON_A = "#ECABC1"
MAROON_B = "#EC92AB"
MAROON_C = "#C55F73"
MAROON_D = "#A24D61"
MAROON_E = "#94424F"
MAROON = "#C55F73"
PURPLE_A = "#CAA3E8"
PURPLE_B = "#B189C6"
PURPLE_C = "#9A72AC"
PURPLE_D = "#715582"
PURPLE_E = "#644172"
PURPLE = "#9A72AC"
PINK = "#D147BD"
LIGHT_PINK = "#DC75CD"
ORANGE = "#FF862F"
LIGHT_BROWN = "#CD853F"
DARK_BROWN = "#8B4513"
GRAY_BROWN = "#736357"
GREY_BROWN = "#736357"

__all__ += [
    "WHITE",
    "GRAY_A",
    "GREY_A",
    "GRAY_B",
    "GREY_B",
    "GRAY_C",
    "GREY_C",
    "GRAY_D",
    "GREY_D",
    "GRAY_E",
    "GREY_E",
    "BLACK",
    "LIGHTER_GRAY",
    "LIGHTER_GREY",
    "LIGHT_GRAY",
    "LIGHT_GREY",
    "GRAY",
    "GREY",
    "DARK_GRAY",
    "DARK_GREY",
    "DARKER_GRAY",
    "DARKER_GREY",
    "BLUE_A",
    "BLUE_B",
    "BLUE_C",
    "BLUE_D",
    "BLUE_E",
    "PURE_BLUE",
    "BLUE",
    "DARK_BLUE",
    "TEAL_A",
    "TEAL_B",
    "TEAL_C",
    "TEAL_D",
    "TEAL_E",
    "TEAL",
    "GREEN_A",
    "GREEN_B",
    "GREEN_C",
    "GREEN_D",
    "GREEN_E",
    "PURE_GREEN",
    "GREEN",
    "YELLOW_A",
    "YELLOW_B",
    "YELLOW_C",
    "YELLOW_D",
    "YELLOW_E",
    "YELLOW",
    "GOLD_A",
    "GOLD_B",
    "GOLD_C",
    "GOLD_D",
    "GOLD_E",
    "GOLD",
    "RED_A",
    "RED_B",
    "RED_C",
    "RED_D",
    "RED_E",
    "PURE_RED",
    "RED",
    "MAROON_A",
    "MAROON_B",
    "MAROON_C",
    "MAROON_D",
    "MAROON_E",
    "MAROON",
    "PURPLE_A",
    "PURPLE_B",
    "PURPLE_C",
    "PURPLE_D",
    "PURPLE_E",
    "PURPLE",
    "PINK",
    "LIGHT_PINK",
    "ORANGE",
    "LIGHT_BROWN",
    "DARK_BROWN",
    "GRAY_BROWN",
    "GREY_BROWN",
]

]

created time in 10 days

issue commentManimCommunity/manim

Add typings

Seems like this never went anywhere? Bit of a shame. Makes it way harder to learn for beginners.

PgBiel

comment created time in 10 days

issue commentmicrosoft/debugpy

Provide public API to attach debugger in excepthook and see unhandled exception

This worked perfectly, thank you so much!!

Timmmm

comment created time in 11 days

issue openedmicrosoft/debugpy

Help needed: Custom exception handler

Hi,

I'm trying to set up debugpy to listen() and wait_for_client() when an exception is thrown. Unfortunately I have to do it like this because I'm looking for one exception from a janky hodgepodge of embedded Python processes and Makefiles.

With the following code:

import debugpy

print("Waiting for debugpy on port 5678.")
debugpy.listen(5678)
debugpy.wait_for_client()

raise Exception("test")

If I run python3 main.py and then connect to it, it catches the exception (great):

image

But I can't figure out how to wait for the client on demand when an exception is thrown. Here is my attempt:

import sys
from types import TracebackType
from typing import Any, Callable, Type

def make_debugpy_excepthook() -> Callable[[Type[BaseException], BaseException, TracebackType], Any]:
    """
    Return an excepthook that will initialise debugpy and then call through to
    its exception handler.
    """
    import debugpy

    original_debugpy_excepthook = sys.excepthook

    def debugpy_excepthook(
        type_: Type[BaseException],
        value: BaseException,
        traceback: TracebackType,
    ) -> Any:
        """
        Callback called when an exception is hit and debugpy is enabled.
        """
        if not debugpy.is_client_connected():
            print("Exception thrown. Waiting for debugpy on port 5678.")
            debugpy.listen(5678)
            debugpy.wait_for_client()

        original_debugpy_excepthook(type_, value, traceback)

    return debugpy_excepthook

sys.excepthook = make_debugpy_excepthook()

raise Exception("test")

Unfortunately if I run it it does wait for the debugger, but then it just prints the traceback in the console. I can't figure out how debugpy actually catches exceptions. Does it even use excepthook? Any help appreciated!

created time in 11 days