Skip to content

Conversation

@fcollonval
Copy link
Contributor

@fcollonval fcollonval commented Dec 30, 2024

Fixes #2198

@fcollonval
Copy link
Contributor Author

fcollonval commented Dec 30, 2024

Unsure about the mypy error, should I just ignore them?

nbconvert/filters/markdown_mistune.py:106: error: Cannot override class variable (previously declared on base class "BlockParser") with instance variable  [misc]
nbconvert/filters/markdown_mistune.py:106: note: Error code "misc" not covered by "type: ignore" comment
nbconvert/filters/markdown_mistune.py:148: error: Cannot override class variable (previously declared on base class "InlineParser") with instance variable  [misc]
nbconvert/filters/markdown_mistune.py:486: error: Argument 4 to "__init__" of "Markdown" has incompatible type "Iterable[Callable[[Markdown], None]]"; expected "Optional[Iterable[Plugin]]"  [arg-type]

@fcollonval fcollonval marked this pull request as ready for review December 30, 2024 11:08
@abbasidaniyal
Copy link

Hey @fcollonval!
Thanks for raising this PR. This patch seems to fix the issue for me.

@laurencap laurencap mentioned this pull request Dec 30, 2024
@bollwyvl
Copy link
Contributor

mypy error

Yeah, we should fix them if we can.

106 and 148 vs upstream:

DEFAULT_RULES: ClassVar[Iterable[str]]  = 

For 486 needs a bit of a forensics to figure out why we have our own type there...

@bollwyvl
Copy link
Contributor

Ah, the Plugin thing is just a protocol. I guess we could backfill that:

    try:
        from mistune.plugins import Plugin
    except ImportError:
        class Plugin(Protocol):
            def __call__(self, markdown: "Markdown") -> None: ...

But really much of it could be hidden behind TYPE_CHECKING...

@fcollonval
Copy link
Contributor Author

Thanks a lot for the hints @bollwyvl

@bollwyvl
Copy link
Contributor

So a quick glance a the CI doesn't tell me whether we're getting coverage against older versions of mistune.

For the offending link:

http://damianavila.github.io/blog/posts/one-line-deployment-of-your-site-to-gh-pages.html
# changed to
https://damianavila.github.io/blog/posts/one-line-deployment-of-your-site-to-gh-pages

@bollwyvl
Copy link
Contributor

Here's a thing from nbformat:

  test_minimum_versions:
    name: Test Minimum Versions
    timeout-minutes: 20
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Base Setup
        uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
        with:
          dependency_type: minimum
      - name: Run the unit tests
        run: |
          hatch run test:nowarn || hatch run test:nowarn --lf

We should probably get that in there and and least see what we can see.

@krassowski
Copy link
Member

It looks like test_minimum_versions is already here? I can see it running: https://github.com/jupyter/nbconvert/actions/runs/12580785345/job/35063360841?pr=2199

test_minimum_versions:
name: Test Minimum Versions
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
dependency_type: minimum
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install texlive-plain-generic inkscape texlive-xetex latexmk
sudo apt-get install xvfb x11-utils libxkbcommon-x11-0 libxcb-xinerama0 python3-pyqt5
# pandoc is not up to date in the ubuntu repos, so we install directly
wget https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-1-amd64.deb && sudo dpkg -i pandoc-2.9.2.1-1-amd64.deb
- name: Run tests
run: |
# Attempt to work around https://github.com/pypa/pip/issues/12781
PIP_CONSTRAINT= hatch env run -e test -- pip install 'pip>=24.2'
xvfb-run --auto-servernum hatch run test:nowarn || xvfb-run --auto-servernum hatch run test:nowarn --lf

@krassowski
Copy link
Member

Looks good to me:

image

@fcollonval
Copy link
Contributor Author

Thanks @krassowski for pushing this. I arrived at the same conclusion. So I pushed a new commit to add a test for mistune 3.0 ... hopefully.

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fcollonval!

@krassowski krassowski merged commit 18e10f6 into jupyter:main Jan 2, 2025
24 checks passed
@bollwyvl
Copy link
Contributor

bollwyvl commented Jan 2, 2025

Huzzah! Happy New Year!

@fcollonval fcollonval deleted the patch-1 branch January 6, 2025 07:54
@Heitapval
Copy link

I installed nbconvert from pypi.

"jupyter nbconvert --to html jarvi.ipynb" gives the error

MathBlockParser' object has no attribute 'parse_axt_heading'. Did you mean: 'parse_atx_heading

@krassowski
Copy link
Member

krassowski commented Mar 15, 2025

@Heitapval and which version jupyter nbconvert --version shows?

@Heitapval
Copy link

@Heitapval and which version jupyter nbconvert --version shows?

The version is 7.16.4

@krassowski
Copy link
Member

The version is 7.16.4

The fix was released in nbconvert v7.16.5 as mentioned before in #2198 (comment) - you need to upgrade nbconvert or find out why pip installed an older version.

@Heitapval
Copy link

The version is 7.16.4

The fix was released in nbconvert v7.16.5 as mentioned before in #2198 (comment) - you need to upgrade nbconvert or find out why pip installed an older version.

Thanks a lot. I got version 7.16.6

I have created a virtual environment with --system-site-packages. I had installed jupyterlab including nbconvert also to my opensuse. I have upgraded with pip3.13 install --upgrade --no-cache-dir -r <req_file>. Usually pip has seemed to upgrade to the latest version when opensuse has an older version. Maybe there were some dependencies.

I uninstalled nbconvert from my opensuse (which uninstalled a lot of other packages.)

pip --force-reinstall might have worked as well

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with mistune V3.1.0

5 participants