Talip7/scikit-learn-issues-multilabel huggingface dataset:
Unable to successfully install scikit-learn development version with MacBookPro with chip Apple M1 Pro

### Describe the bug

I installed the development version of scikit-learn on my computer (MacBookPro with chip Apple M1 Pro). When I ran pytest I got the following error: 
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```

I investigated what's going on an this is the result: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

I'm using a conda environment. I used the Miniforge3-MacOSX-arm64 download from here: https://github.com/conda-forge/miniforge#miniforge

This is the content of my sklearn-dev conda environment: 
https://gist.github.com/marenwestermann/c01fc4d3044522e329ce83d16680e1a5

### Steps/Code to Reproduce

```
pytest
```

```
python -vvv -c "import sklearn"
```

### Expected Results

The expected result would be that when the command `pytest` is run all test are either skipped or are successful. 

### Actual Results

Pytest result:
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```
Further investigation: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

### Versions

```shell
function>
```

COMMENT:
I can also confirm that the issue is fixed. I created a new conda environment with `python=3.10` and everything works fine.

Labels: Bug, Build / CI
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
Thanks for opening the issue! Since `pytest.warns(None)` is deprecated,  It makes sense to update our tests to use `warnings.catch_warnings(record=True)`.

To be specific:

```python
    with pytest.warns(None) as record:
        ...
```

can be directly replaced with:

```python
    with warnings.catch_warnings(record=True) as record:
        ...
```

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
Hello - I'd like to help tackle this problem if that'd be alright? If someone else is already working on this please just let me know!

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
Hello @ShanDeng123 
As far as I understand, all the items on cmarmo's list are independent and she asked to do 1 file per pull request.
I suppose, you can write here to reserve a bunch of them (e.g., `sklearn/cluster/tests/*.*`), then take the next bunch, and so on. 
I am not working on this issue.

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
I am curious if the issue is more complex than Find-Replace... And if `pytest.warns(None)` in the existing code was always used and understood correctly.

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:

For this specific case, I am okay with one PR that does a "Find and Replace" replacing all the `with pytest.warns(None) as record:` with `with warnings.catch_warnings(record=True) as record:`.


I think it's better to do one PR per file. See https://github.com/scikit-learn/scikit-learn/issues/22572#issuecomment-1066284782 for details.

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
@avm19 
Sounds good - I can look to do the first 10 in the list up until the last file under the ensemble folder, and can continue working on the others afterwards if nobody else hops on.

@thomasjpfan 
I can look to merge updates for multiple files in a single PR as I go! I do want to make sure that I'm following all of the proper guidelines/precautions though as I am still a bit new to open source work. Would hate to cause any unnecessary issues! 😅

That being said - would any of you guys know if this would necessitate an update to the [changelog](https://github.com/scikit-learn/scikit-learn/blob/main/doc/whats_new/v1.1.rst) document? And if so, would the note be a bullet under the main **Changelog** header?

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
It is not necessary to update the changelog, since it is not a public facing change.

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
Coming from https://github.com/scikit-learn/scikit-learn/pull/22822#issuecomment-1066283823 I think it's better to do this one per file.

When we write the following to test for no warnings:

```python
with pytest.warns(None) as record:
    ...
assert not [w.message for w in record]
```

I think the better solution is to replace that with:

```python
with warnings.catch_warnings():
    warnings.simplefilter("error", EXPECTED_WARNING)
    ...
```

where `EXPECTED_WARNING` is the warning we expect to **not** happen. Since this is a non-trival change, I think it's better a one PR per file.

If we do not know the expected warning then we can write:

```python
with warnings.catch_warnings():
    warnings.simplefilter("error")
    ...
```

(But I prefer to have the expected warning)

Labels: good first issue, module:test-suite, Meta-issue
pytest warnings due to deprecation of pytest.warns(None)

Pytest issues warnings about using `pytest.warns(None)` context manager, where the `None` part is now being deprecated. 

For example,
```>>> pytest ./sklearn/tests/test_naive_bayes.py ```
results in `79 passed, 4 warnings`. After commenting out `--disable-pytest-warnings` key in `[tool:pytest]` section of `setup.cfg`, I could see that _some_ of the warnings are:

> PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Apparently, `pytest.warns(None)` is deprecated for being widely misunderstood. I think that while sklearn's tests do _not_ suffer from this misunderstanding, they might be affected in the future if and when pytest raises an error instead of a deprecation warning. (I couldn't figure out if this is planned for pytest's future releases, but in any case, avoiding the deprecation and reducing the warnings count won't harm.)

I found [this message ](https://github.com/pytest-dev/pytest/issues/9404#issuecomment-991051965), which is relevant to how `pytest.warns(None)` is used in scikit-learn tests, and how this could be changed. I opened this issue to share this information and quote the message, as it may save someone time in the future.

> The tests were of the form:
> 
> ```
> with pytest.warns(None) as record:
>     <do some stuff>
>     <check record for warnings, and possibly raise an error>
> ```
> 
> The tests were not assuming that the pytest context code would raise an error if a warning occurred. Instead, these tests were doing their own error checking based on `record`. So they were really using `pytest.warns(None)` exactly like `warnings.catch_warnings(record=True)`. (There is a [pull request](https://github.com/scipy/scipy/pull/15192) to make the change to `catch_warnings`.)

COMMENT:
Will do - I'll go back over the files with 1 PR each, and look to add the extra detail when applicable 👍

Labels: good first issue, module:test-suite, Meta-issue