Skip to content

Conversation

@jessegrabowski
Copy link
Member

Very small changes to reflect how this script is used by developers:

  • --verbose is now the default
  • By default, "expected" failures are filtered. You can see all failures by passing a --show-expected flag.

Justifications:

  1. I have never run this command without --verbose, so why not?
  2. The way this script is used is to fix mypy problems with a specific PR. This requires fixing only the new failures. Unless we're actively working on cleaning up the code base, we're only interested in the new failures.

@jessegrabowski jessegrabowski added the no releasenotes Skipped in automatic release notes generation label Nov 16, 2025
@jessegrabowski
Copy link
Member Author

It was pointed out here that we should just be using --output json instead of manually parsing the mypy output, so I've also done that.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors run_mypy.py to improve the developer experience by making verbose output the default and filtering out expected failures unless explicitly requested. The script now uses mypy's JSON output format instead of custom text parsing.

Key changes:

  • Switched from custom text parsing to mypy's native JSON output format via pd.read_json()
  • Made --verbose the default behavior (default=1) and added --show-expected flag to control failure filtering
  • Updated error messages to guide users based on the new default behavior
Comments suppressed due to low confidence (1)

scripts/run_mypy.py:142

  • The --groupby option help text mentions {file|errorcode|message} but the new code uses column names from mypy's JSON output. If the JSON output doesn't have an errorcode column (it likely has code instead based on line 164), then --groupby errorcode will fail. The help text should be updated to match the actual available columns in the DataFrame.
        "--groupby",
        default="file",
        help="How to group verbose output. One of {file|errorcode|message}.",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

else:
print("\nThese files did not fail before. Fix all errors reported in the output above.")
print(
f"\nNote: In addition to these errors, {len(failing.intersection(expected_failing))} errors in files "
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

This counts the number of files with expected failures, not the number of individual errors. The message is misleading because it says "{count} errors in files" when it actually means "errors from {count} files". Consider rephrasing to: "In addition to these errors, errors from {count} files marked as 'expected failures' were also found."

Suggested change
f"\nNote: In addition to these errors, {len(failing.intersection(expected_failing))} errors in files "
f"\nNote: In addition to these errors, errors from {len(failing.intersection(expected_failing))} files "

Copilot uses AI. Check for mistakes.
parser = argparse.ArgumentParser(description="Run mypy type checks on PyMC codebase.")
parser.add_argument(
"--verbose", action="count", default=0, help="Pass this to print mypy output."
"--verbose", action="count", default=1, help="Pass this to print mypy output."
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The help text for --verbose is now misleading. Since default=1 makes verbose mode enabled by default, the help text should reflect this. Consider changing it to something like "Verbose output is enabled by default. Pass --verbose 0 to suppress output." or simply removing this argument in favor of a --quiet flag.

Suggested change
"--verbose", action="count", default=1, help="Pass this to print mypy output."
"--verbose", action="count", default=1, help="Verbose output is enabled by default. Pass --verbose 0 to suppress output."

Copilot uses AI. Check for mistakes.
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@ricardoV94 ricardoV94 merged commit 4ad7fa8 into pymc-devs:main Nov 18, 2025
19 checks passed
@Armavica
Copy link
Member

Ohh thank you for this change!

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

Labels

no releasenotes Skipped in automatic release notes generation pre-commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants