Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for mistune 3.1.0 #2199

Merged
merged 13 commits into from
Jan 2, 2025
Merged

Add support for mistune 3.1.0 #2199

merged 13 commits into from
Jan 2, 2025

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
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
4 participants