GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make pygments mandatory and fix string highlighting by The-Compiler · Pull Request #13189 · pytest-dev/pytest

Conversation

@The-Compiler

@The-Compiler The-Compiler commented Feb 3, 2025

Copy link
Copy Markdown
Member
  • Closes Add "color" install extra #7683
  • Fixes (🎁) color the diff of strings #13175

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk reacted with hooray emoji KotlinIsland reacted with rocket emoji
All reactions
  • 🎉 1 reaction
  • 🚀 1 reaction
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Feb 3, 2025
This was referenced Feb 3, 2025
Add "color" install extra #7683
Closed
(🎁) color the diff of strings #13175
Closed
nicoddemus
nicoddemus approved these changes Feb 3, 2025
View reviewed changes

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Awesome, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@The-Compiler
The-Compiler force-pushed the pygments-improvements branch from 747caba to 44e9f68 Compare February 3, 2025 18:06
@The-Compiler

The-Compiler commented Feb 3, 2025

Copy link
Copy Markdown
Member Author

Didn't quite work out as planned, as I didn't see that the not in assertion output also uses _diff_text, but then post-processes the diff to show a nicer output:

pytest/src/_pytest/assertion/util.py

Lines 590 to 599 in afdf03b

newdiff = [f"{saferepr(term, maxsize=42)} is contained here:"]
for line in diff:
if line.startswith("Skipping"):
continue
if line.startswith("- "):
continue
if line.startswith("+ "):
newdiff.append(" " + line[2:])
else:
newdiff.append(line)

Opted to add a dummy_highlighter function to avoid having to special-case this in _diff_text, WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Feb 3, 2025

Copy link
Copy Markdown
Member

Opted to add a dummy_highlighter function to avoid having to special-case this in _diff_text, WDYT?

Sounds good to me. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BenjaminSchubert
BenjaminSchubert approved these changes Feb 3, 2025
View reviewed changes

@BenjaminSchubert BenjaminSchubert left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks great, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
KotlinIsland
KotlinIsland reviewed Feb 3, 2025
View reviewed changes

@KotlinIsland KotlinIsland left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

awesome PR, this is a very welcome change

I think it would make sense to document the extra somewhere. explain why it exists/what it does

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@The-Compiler

The-Compiler commented Feb 4, 2025

Copy link
Copy Markdown
Member Author

I think it would make sense to document the extra somewhere. explain why it exists/what it does

I don't think there's a good place for this in the docs, especially because we don't do this kind of thing for any of the other dependencies either. And if you see it in action (and/or know what Pygments does), I think it's kind of obvious.

KotlinIsland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KotlinIsland

KotlinIsland commented Feb 4, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

think it's kind of obvious

I have no idea what pygments is/does, and I have no idea how to discover if a package has any extras or not. I think not stating that this extra functionality is available would be a disservice to your users 🙂

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@The-Compiler

The-Compiler commented Feb 4, 2025

Copy link
Copy Markdown
Member Author

This PR makes it a dependency, not an extra. You don't need to know it exists, you will just get syntax highlighting after installing pytest.

KotlinIsland reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KotlinIsland

KotlinIsland commented Feb 4, 2025

Copy link
Copy Markdown

oh, my mistake! sorry, okay that's great!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nicoddemus
nicoddemus reviewed Feb 4, 2025
View reviewed changes
Comment thread changelog/7683.improvement.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@The-Compiler
The-Compiler force-pushed the pygments-improvements branch from 44e9f68 to ca6557e Compare February 4, 2025 16:52
The-Compiler added 2 commits February 4, 2025 17:53
@The-Compiler
Make pygments dependency required
0332aa0
Closes pytest-dev#7683
@The-Compiler
Also highlight comparisons between strings
cb089b6
Fixes pytest-dev#13175
@The-Compiler
The-Compiler force-pushed the pygments-improvements branch from ca6557e to cb089b6 Compare February 4, 2025 16:53
@The-Compiler

The-Compiler commented Feb 5, 2025

Copy link
Copy Markdown
Member Author

@Pierre-Sassoulas @Zac-HD @RonnyPfannschmidt Do you have any objections/concerns with adding Pygments as a default dependency (at least until PEP 771 – Default Extras for Python Software Packages | peps.python.org is a thing), or should I merge this?

(Sorry for the explicit ping - not asking for a full review as I think we have this covered, just for an opinion on the dependency because I'd like to give everyone a chance to speak up if there is some implication I didn't consider)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

RonnyPfannschmidt
RonnyPfannschmidt approved these changes Feb 5, 2025
View reviewed changes
@Zac-HD

Zac-HD commented Feb 5, 2025

Copy link
Copy Markdown
Member

In general I prefer minimal dependencies, but I think the case for Pygments is strong enough to add it in this case.

If we do get a default-extras PEP I'd be keen to move it to that and make sure we test without it too though.

Pierre-Sassoulas, The-Compiler, and RonnyPfannschmidt reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Pierre-Sassoulas
Pierre-Sassoulas approved these changes Feb 5, 2025
View reviewed changes
@hugovk

hugovk commented Feb 7, 2025

Copy link
Copy Markdown
Member

(at least until PEP 771 – Default Extras for Python Software Packages | peps.python.org is a thing)

The PEP is now up for discussion, please leave a comment if you'd like to add your support or give other feedback:

https://discuss.python.org/t/pep-771-default-extras-for-python-software-packages/79706

Zac-HD, The-Compiler, and Pierre-Sassoulas reacted with heart emoji
All reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@The-Compiler
The-Compiler merged commit a3d55a6 into pytest-dev:main Feb 8, 2025
@Zac-HD Zac-HD mentioned this pull request Jul 22, 2026
New code highlighting tests fail on Mageia 8 buildsystem #6938
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nicoddemus nicoddemus nicoddemus approved these changes
@RonnyPfannschmidt RonnyPfannschmidt RonnyPfannschmidt approved these changes
@BenjaminSchubert BenjaminSchubert BenjaminSchubert approved these changes
@Pierre-Sassoulas Pierre-Sassoulas Pierre-Sassoulas approved these changes
+1 more reviewer
@KotlinIsland KotlinIsland KotlinIsland left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

(🎁) color the diff of strings Add "color" install extra

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@The-Compiler @nicoddemus @KotlinIsland @Zac-HD @hugovk @RonnyPfannschmidt @BenjaminSchubert @Pierre-Sassoulas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.