ipython / ipython/ipykernel

Suggestion: append info about code block number in filename

Offen
#716 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
734
Forks
412
Ø Merge
1 T. 5 Std.
Gemergte PRs (30 T.)
8

Beschreibung

When using IPython, the "filename" contains the number information of the code block that contains it; this is something of the form `` where `N` is the code block number.
![image](https://user-images.githubusercontent.com/629698/125211587-bfb48400-e27d-11eb-9a17-32f9d488aaa4.png)

When actual temporary files are used in the ipykernel, the names created on https://github.com/ipython/ipykernel/blob/b2f1a79f64c49a1c54f2e7c79c062d6b347b9bf0/ipykernel/compiler.py#L50 lose that information.
My suggestion would be to append `_number` to the filename where `number` is the code block number. So, instead of `path/to/filename.py` one would have `path/to/filename_number.py`. This would enable a human reader to identify which code block is involved in the traceback.

Additionally, while it is currently possible to programmatically obtain the information and having a "filename" much more understable, as demonstrated in the image below, there can be some ambiguity if the exact same content appears in two code blocks, one of which appearing in a traceback (as shown in the second traceback in the image below).

Adding the `_number` would remove this ambiguity.
![image](https://user-images.githubusercontent.com/629698/125211724-ce4f6b00-e27e-11eb-8d5c-07e6a8e90ff3.png)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with ipykernel/compiler.py around line 50, where temporary filenames are created, and trace how the code block number is available when that filename is assembled. Confirm the desired filename format for traceback entries and check existing tests around compiler or temporary-file naming; done means filenames retain the code block number without losing the readable path information.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.