Enabled ruff TCH on some files
State: closed

 #51740 for the following elements:
- [ ] "pandas/core/apply.py": no change was required
- [ ] "pandas/core/base.py": no change was required
- [ ] "pandas/core/algorithms.py": no change was required
- [ ] "pandas/core/ops/*"
- [ ] "pandas/core/sorting.py"

No change was required means that the command:
`pre-commit run ruff --all-files`
had zero errors after removing the relative line from the `pyproject.toml` file without any change (can be tried by doing so in the main branch).

Labels:
name: Code Style
description: Code style, linting, code_checks

Comments:
thanks for your PR - can you run `pre-commit run --all-files`?
> 

I ran it and get the following output:
```
black...................................................................................................Failed
- hook id: black
- files were modified by this hook

reformatted pandas/core/ops/dispatch.py
reformatted pandas/core/ops/common.py
reformatted pandas/core/ops/array_ops.py

All done! ✨ 🍰 ✨
3 files reformatted, 1506 files left unchanged.

ruff....................................................................................................Passed
vulture.................................................................................................Passed
codespell...............................................................................................Passed
cython-lint.............................................................................................Passed
double-quote Cython strings.............................................................................Passed
debug statements (python)...............................................................................Passed
fix end of files........................................................................................Passed
trim trailing whitespace................................................................................Passed
cpplint.................................................................................................Passed
isort...................................................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/et/Repos/Python/pandas-ErdiTk/pandas/core/ops/__init__.py
Fixing /home/et/Repos/Python/pandas-ErdiTk/pandas/core/ops/array_ops.py
Fixing /home/et/Repos/Python/pandas-ErdiTk/pandas/core/ops/common.py
Fixing /home/et/Repos/Python/pandas-ErdiTk/pandas/core/ops/dispatch.py
Skipped 1 files

pyupgrade...............................................................................................Passed
rst ``code`` is two backticks...........................................................................Passed
rst directives end with two colons......................................................................Passed
rst ``inline code`` next to normal text.................................................................Passed
Sphinx lint.............................................................................................Passed
flake8-rst..............................................................................................Failed
- hook id: flake8-rst
- exit code: 1

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 31
    df.plot.<TAB>  # noqa: E225, E999
            ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 103
    @tm.network   # noqa
    ^
IndentationError: expected an indented block after 'with' statement on line 101

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 203
    df.foo<TAB>  # noqa: E225, E999
                 ^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 35
    df.plot.<TAB>  # noqa: E225, E999
            ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 28
    -l 4 df.apply(lambda x: integrate_f(x["a"], x["b"], x["N"]), axis=1)  # noqa E999
       ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 27
    df2.<TAB>  # noqa: E225, E999
        ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 486, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/processor.py", line 212, in build_ast
    return compile("".join(self.lines), "", "exec", PyCF_ONLY_AST)
  File "", line 84
    gb.<TAB>  # noqa: E225, E999
       ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/bin/flake8-rst", line 8, in <module>
    sys.exit(main())
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8_rst/cli.py", line 16, in main
    app.run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 488, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/et/.cache/pre-commit/repo65ueqkql/py_env-python3.10/lib/python3.10/site-packages/flake8/checker.py", line 473, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'

Check for inconsistent use of pandas namespace..........................................................Passed
Check code for instances of os.remove...................................................................Passed
Unwanted patterns.......................................................................................Passed
Check Cython casting is `<type>obj`, not `<type> obj`...................................................Passed
Check for backticks incorrectly rendering because of missing spaces.....................................Passed
Check for unnecessary random seeds in asv benchmarks....................................................Passed
Check for usage of numpy testing or array_equal.........................................................Passed
Check for invalid EA testing............................................................................Passed
Unwanted patterns in tests..............................................................................Passed
Unwanted patterns in EA tests...........................................................................Passed
Unwanted patterns in Cython code........................................................................Passed
Generate pip dependency from conda......................................................................Passed
Validate correct capitalization among titles in documentation...........................................Passed
Check for use of bare pytest raises.....................................................................Passed
Check for use of private functions across modules.......................................................Passed
Check for import of private attributes across modules...................................................Passed
Check for strings with misplaced spaces.................................................................Passed
Import pandas.array as pd_array in core.................................................................Passed
Use pandas.io.common.urlopen instead of urllib.request.urlopen..........................................Passed
Use bool_t instead of bool in pandas/core/generic.py....................................................Passed
Use raise instead of return for exceptions..............................................................Passed
Ensure pandas errors are documented in doc/source/reference/testing.rst.................................Passed
Check for pg8000 not installed on CI for test_pg8000_sqlalchemy_passthrough_error.......................Passed
Check minimum version of dependencies are aligned.......................................................Passed
Validate errors locations...............................................................................Passed
flake8-pyi..............................................................................................Passed
import annotations from __future__......................................................................Passed
check that test names start with 'test'.................................................................Passed
sort whatsnew entries by issue number...................................................................Passed
```
thanks @ErdiTk - looks like `flake8-rst` breaks on python3.10

indeed, it's unmaintained. we should probably just remove it - do you feel like making a separate PR to just remove it?

for now, for this PR, you could do
```
SKIP=flake8-rst pre-commit run --all-files
```
> thanks @ErdiTk - looks like `flake8-rst` breaks on python3.10
> 
> indeed, it's unmaintained. we should probably just remove it - do you feel like making a separate PR to just remove it?
> 
> for now, for this PR, you could do
> 
> ```
> SKIP=flake8-rst pre-commit run --all-files
> ```

No problem, I will create a separate PR to remove the flake8-rst. Indeed seems unmaintained, last update was in 2020. Shall I link it to this PR or are you going to create a new Issue for it? 

Moreover, the line:
```
SKIP=flake8-rst pre-commit run --all-files
```
Should be added in the `pyproject.toml` file right? (sorry fi the question is naive but I am still learning how the process works)
linking to this PR seems fine

not sure what you mean by your second question, but that doesn't need to go in pyproject.toml
> 

Sorry I understood now. Will make soon the PR where I remove fake8-rst.