Skip to content

Conversation

@oscarkey
Copy link
Contributor

Enable the ANN rules, but exclude some overly strict ones, in line with our other repositories.

I added type annotations where they were missing. I also:

  • ignore ANN for src/tabpfn/architectures/base/preprocessing.py, due to a lot of errors
  • delete a class and a method that were not used in any PriorLabs repository
  • add noqa in some cases where the type was not obvious, to avoid getting it wrong

These are the ANN rules, but exclude some overly strict ones.

I added type annotations where they were missing. I also:
- ignore ANN for src/tabpfn/architectures/base/preprocessing.py, due to
  a lot of errors
- delete a class and a method that were not used in any PriorLabs
  repository
- add noqa in some cases where the type was not obvious, to avoid
  getting it wrong
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @oscarkey, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to enhance code quality and maintainability by enabling and enforcing type annotation rules (ANN) within the Ruff linter configuration. It systematically adds missing type annotations across the codebase, while also making pragmatic exceptions for overly strict rules and specific files to balance strictness with development efficiency. Additionally, it cleans up unused code.

Highlights

  • Linter Configuration Update: Activated Ruff's "ANN" rules for type annotation enforcement in "pyproject.toml".
  • Targeted Rule Exemptions: Configured Ruff to ignore specific "ANN" rules (e.g., "ANN002" for "*args", "ANN003" for "**kwargs", "ANN204" for "init", "ANN401" for "Any") to avoid overly strict checks.
  • File-Specific Exclusions: Excluded "src/tabpfn/architectures/base/preprocessing.py" from all "ANN" checks due to a high volume of existing errors.
  • Extensive Type Annotation Additions: Applied numerous type annotations to function parameters and return types across various Python files (e.g., examples, src/tabpfn/architectures, src/tabpfn/classifier.py, src/tabpfn/inference.py, src/tabpfn/preprocessing.py, src/tabpfn/utils.py, tests/).
  • Code Cleanup: Removed the "StyleEncoder" class and "get_linear_encoder_generator" function from "src/tabpfn/architectures/base/encoders.py" as they were identified as unused.
  • "noqa" Annotations: Added "noqa" comments in cases where type inference was not straightforward, ensuring linter compliance without sacrificing clarity.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@oscarkey oscarkey requested a review from priorphil August 14, 2025 15:33
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enables Ruff's ANN rules to enforce type annotations, a great step towards improving code quality and maintainability. The changes primarily involve adding missing type hints across various files, along with necessary configuration adjustments in pyproject.toml to manage the new rules. The removal of unused code is also a welcome cleanup.

I've found one issue regarding an incorrect return type hint (NoReturn instead of None) in a base class method in src/tabpfn/inference.py. This violates type compatibility with subclass implementations and should be corrected. My detailed feedback is in the comment below.

Copy link
Contributor

@priorphil priorphil left a comment

Choose a reason for hiding this comment

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

Thanks for adding these!

@oscarkey oscarkey merged commit 9b7ecc9 into main Aug 15, 2025
10 checks passed
@oscarkey oscarkey deleted the ok-ruff-ann branch August 15, 2025 09:01
oscarkey added a commit that referenced this pull request Nov 12, 2025
…107)

* Enable type annotation rules in the Ruff linter. (#451)

(cherry picked from commit 9b7ecc9)

* Record copied public PR 451

* Add noqa.

---------

Co-authored-by: Oscar Key <oscar@priorlabs.ai>
Co-authored-by: mirror-bot <mirror-bot@users.noreply.github.com>
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.

3 participants