STY: remove --keep-runtime-typing from pyupgrade Part-1
State: closed

- [x] xref #40759
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [ ] whatsnew entry


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

Comments:
The mypy failures are due to the fact that some of these methods have their own method `type`, which interferes with the built-in `type`

small example:
```python
# t.py

from __future__ import annotations
from typing import Type


class Cat:
    
    def type(self) -> str:
        return 'this is my type'

    def type_cat(self) -> Type[Cat]:
        return Cat
```

works fine:
```console
$ mypy t.py 
Success: no issues found in 1 source file
```
but the following:
```python
# t.py

from __future__ import annotations
from typing import Type


class Cat:
    
    def type(self) -> str:
        return 'this is my type'

    def type_cat(self) -> type[Cat]:
        return Cat
```
doesn't:
```console
$ mypy t.py 
t.py:10: error: Function "t.Cat.type" is not valid as a type
t.py:10: note: Perhaps you need "Callable[...]" or a callback protocol?
Found 1 error in 1 file (checked 1 source file)
```
If we moved the definitions around so that `type_cat` came before `type`, it would work.

---

I think the solution here is to define the alias `type_t = type` in `pandas/_typing.py`, and then import that, and use it here. This seems analogous to using `bool_t` in `pandas/core/generic.py` (#40175)

cc @WillAyd @simonjayhawkins 

EDIT
----

Actually, using `type_t` as I'd suggested doesn't work, as then we get
```console
$ mypy t.py 
t.py:12: error: "type" expects no type arguments, but 1 given  [type-arg]
Found 1 error in 1 file (checked 1 source file)
```

will think of how to do this

---

EDIT2
----

This seems to work:

in `pandas/_typing.py`, apply the diff
```diff
diff --git a/pandas/_typing.py b/pandas/_typing.py
index f90ef33434..c11cfc0f21 100644
--- a/pandas/_typing.py
+++ b/pandas/_typing.py
@@ -25,7 +25,7 @@ from typing import (
     Optional,
     Sequence,
diff --git a/pandas/_typing.py b/pandas/_typing.py
index f90ef33434..c11cfc0f21 100644
--- a/pandas/_typing.py
+++ b/pandas/_typing.py
@@ -25,7 +25,7 @@ from typing import (
     Optional,
     Sequence,
     Tuple,
-    Type,
+    Type as Type_t,
     TypeVar,
     Union,
 )
@@ -119,7 +119,7 @@ Axes = Collection[Any]
 # dtypes
 NpDtype = Union[str, np.dtype]
 Dtype = Union[
-    "ExtensionDtype", NpDtype, Type[Union[str, float, int, complex, bool, object]]
+    "ExtensionDtype", NpDtype, Type_t[Union[str, float, int, complex, bool, object]]
 ]
 # DtypeArg specifies all allowable dtypes in a functions its dtype argument
 DtypeArg = Union[Dtype, Dict[Hashable, Dtype]]
@@ -187,3 +187,5 @@ ColspaceArgType = Union[
 # internals
 Manager = Union["ArrayManager", "BlockManager"]
 SingleManager = Union["SingleArrayManager", "SingleBlockManager"]
```

then for any of the lines that are throwing errors, in those files, import `Type_t` from `pandas/_typing.py`, and use `Type_t` instead of `type` in the problematic annotations
Thanks @MarcoGorelli for the nice explanation and suggestion, I have made changes according to that and pushed my code.
Nice, thanks @fathomer ! Let's wait to hear from the others about this `import Type as Type_t` workaround


Looks good, thanks!