Skip to content

Add test and fix stub for sklearn.config_context#3155

Open
fhoehle wants to merge 2 commits intofacebook:mainfrom
fhoehle:fh.fix-sklearn-config_context
Open

Add test and fix stub for sklearn.config_context#3155
fhoehle wants to merge 2 commits intofacebook:mainfrom
fhoehle:fh.fix-sklearn-config_context

Conversation

@fhoehle
Copy link
Copy Markdown

@fhoehle fhoehle commented Apr 15, 2026

Summary

This PR adds a new test asserting that the sklearn.config_context context manager is correctly understood.
The initial failing test is fixed by correcting the corresponding sklearn.config_context type hint and adding the contextlib.contextmanager decorator.

Issue #3154 describes the observed error. The originating cause is the incorrect sklearn-stub in the pyrefly_bundled crate.

The deprecation warning regarding Iterator[None] is mitigated by replacing it with Generator

Test Plan

  • Executing the new (failing) test at 03b707d7bb6aeb55d9c5f2b6dd7b6e7367fe43a4, which failed with the above-described bad-context-manager error.
    cargo test -p pyrefly --lib test_sklearn
  • Successful execution at HEAD of this branch
  • Successful run of test.py

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 15, 2026

Hi @fhoehle!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 15, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Copy Markdown
Contributor

@rchen152 rchen152 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 the PR! Pyrefly's bundled sklearn stubs are mirrored from here:

"repository": "https://github.com/microsoft/python-type-stubs",
. So rather than editing our bundled copy, it would be better to fix the stubs upstream and then bundle a fresh copy.

(If you get pushback on or lack of response to an upstream PR, we can consider doing a local patch instead. We'd need to record the patch somewhere, so we know what we've modified.)

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.

2 participants