Skip to content

Sort notebook violations by cell order, not cell ID#6

Open
PiotrCzapla wants to merge 1 commit intomainfrom
fix-notebook-cell-order
Open

Sort notebook violations by cell order, not cell ID#6
PiotrCzapla wants to merge 1 commit intomainfrom
fix-notebook-cell-order

Conversation

@PiotrCzapla
Copy link

@PiotrCzapla PiotrCzapla commented Feb 2, 2026

I had a hard time finding my edited cells. The tool reports around 100 issues on lisette/00_core.ipynb, and they are in random order (sorted by random cell id). It is hard to filter them. This is a quick fix that prepends cell idx to cell_id, to let me use the tool on a notebook. How would an ideal marker look like? Do we want to include the tool output in solveit?

Here is how the tool output looks like now. I've added violations to mark the range of cells I've modified:

# 00_tmp.ipynb:cell[156#df219bee]:14: if single-statement body not one-liner
    if self.extra_headers: 
        kwargs['extra_headers'] = self.extra_headers # mark the first cell with changes
# 00_tmp.ipynb:cell[157#3580347d]:12: if single-statement body not one-liner
    if prefill: 
        contents(res).content = prefill + (contents(res).content or "")
# 00_tmp.ipynb:cell[161#266f3d5d]:11: if single-statement body not one-liner
    if kwargs.get('stream'): 
        return result_gen # mark the last cell with changes

This brings another issue the tool does not seems report the style violations you seen in the #101 , but I guess the issue was in : _flatmap_call and how it uses match case. Should I try to get this tool to report issues for match/case?

@PiotrCzapla PiotrCzapla requested a review from jph00 February 2, 2026 12:38
@jph00
Copy link
Contributor

jph00 commented Feb 4, 2026

Thanks for the PR! chkstyle is designed to be read and acted on by an AI, not a human :D So the main question I have is, does this help the AI, or confuse it? Maybe chkstyle should first output a line explaining the format?

BTW, why are the issues in random order? Do we sort them? It would be nice if we printed them in notebook order.

@PiotrCzapla
Copy link
Author

We sort them by path, line number. But since path has :cell marker we get random order.

@PiotrCzapla
Copy link
Author

Just having them in the notebook order would be enough. The cell numbers I added don't bring much value if the order is preserved. So we could remove them.
I can update the PR, to sort by notebook order. Then we are back at: 00_tmp.ipynb:cell[df219bee]

But I'm thinking we could go a step further and craft a standard id to address content in notebooks. That works in shell and in the browser, and in tools (like view)

Here are some ideas (not recommendations):
Both # and ? work nicely for web but are hard to work with in bash, same with [] all of these have meaning if I recall. What would you say for something simpler like:

nb:./00_tmp:_df219bee - that makes it clear it is not a file, token wise is not too bad. (ipynb is 3 tokens and nb 1). Works fine in zsh (no quotes needed). The _ in front of id makes it easier to scan for me, (but might be confusing for AI)

We could make it work for web by adding endpoint like &go=nb:./00_tmp:_df219bee that would resolve it based on the current dialog so this url would go to the correct place:
https://priceless-dragon-secures-cj03nr.si.answer.ai/dialog_?name=repos%2Flisette%2Fnbs%2F00_core&go=nb:./00_tmp:_df219bee

or even one step further:
nb=./00_tmp:_df219bee
and have the url construction simplified: &nb=./00_tmp:_df219bee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants