CLN: remove util._decorators.make_signature and make related changes
State: closed

``util._decorators.make_signature`` is only used in ``core.groupby.base.whitelist_method_generator``.

However, in that function it is only used inside an if statement, that is conditional upon an attribute being a method. That however can not happen, as the function parameter only takes classes as an input, so that if-statement is never true and its content never executed. The net effect is that a nice chunk of code can just be removed, which is nice.

In the future, we should just use jus use ``inspect.signature`` or ``inspect.getfullargspecs`` for signature inspection.

Labels:
name: Clean
name: Typing
description: type annotations, mypy/pyright type checking

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=h1) Report
> Merging [#26819](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8374a1d2a58245067669cd6424793b134a695971?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26819/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26819      +/-   ##
==========================================
+ Coverage   91.86%   91.86%   +<.01%     
==========================================
  Files         179      179              
  Lines       50700    50679      -21     
==========================================
- Hits        46576    46557      -19     
+ Misses       4124     4122       -2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.45% <100%> (ø)` | :arrow_up: |
| #single | `41.13% <100%> (-0.05%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlY29yYXRvcnMucHk=) | `92.13% <ø> (+0.78%)` | :arrow_up: |
| [pandas/core/groupby/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9iYXNlLnB5) | `100% <ø> (+8.16%)` | :arrow_up: |
| [pandas/core/groupby/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9nZW5lcmljLnB5) | `89.33% <100%> (+0.16%)` | :arrow_up: |
| [pandas/\_typing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL190eXBpbmcucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26819/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=footer). Last update [8374a1d...bf07b51](https://codecov.io/gh/pandas-dev/pandas/pull/26819?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

The failures are unrelated to this PR
Makes sense to me. I think merging master should get rid of the failure.

Also annotations while you are looking at this would be great if they are easy to add
I've rebased and added type hints.

Wrt. the type hints, I've added the typing specific internal imports inside a ``if TYPE_CHECKING`` statement in order to minimize the risk of circular import problems. I'm however not 100 % strong in correct typing usage, so I see that as point for discussion, not ny final view on pure type importing.

Given that a Union works as well as a TypeVar in this case, and the required TypeVar would actually be ``TypeVar('FrameOrSeries', Type[ABCSeries], Type[ABCDataFrame])`` (notice the extra ``Type``), and this TypeVar would be used very infrequently, I propose just accepting it like is it ATM (a Union).
Might be mixing up a few things here. The TypeVar would look as follows:

```python
FrameOrSeries = TypeVar('FrameOrSeries', ABCSeries, ABCDataFrame)
```

The annotation in question would then be `Type[FrameOrSeries]` as opposed to `Type[Union[Series, DataFrame]]]` as is now (perhaps some slight variations).
Change looks good not sure what's going on with Travis / NumPy failure
lgtm. I restarted the job, should pass. merge on green.
thanks @topper-123