Contributing Guide for Type Hints
State: closed

Want to get this documented as we've been picking up momentum with type hints

@toobaz @TomAugspurger @vaibhavhrt @gwrome @makbigc 

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

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

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

```diff
@@            Coverage Diff             @@
##           master   #27050      +/-   ##
==========================================
- Coverage   92.01%      92%   -0.01%     
==========================================
  Files         180      180              
  Lines       50754    50754              
==========================================
- Hits        46699    46695       -4     
- Misses       4055     4059       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.64% <ø> (ø)` | :arrow_up: |
| #single | `41.85% <ø> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/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/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.89% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27050?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/27050?src=pr&el=footer). Last update [a7f1d69...ea8e560](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=h1) Report
> Merging [#27050](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/45ea26763da832189747ac9f86630fece84b4f18?src=pr&el=desc) will **increase** coverage by `0.17%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #27050      +/-   ##
==========================================
+ Coverage   91.86%   92.03%   +0.17%     
==========================================
  Files         180      180              
  Lines       50792    50714      -78     
==========================================
+ Hits        46658    46675      +17     
+ Misses       4134     4039      -95
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.67% <ø> (+0.18%)` | :arrow_up: |
| #single | `41.86% <ø> (-0.11%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `96.3% <0%> (-1.32%)` | :arrow_down: |
| [pandas/core/internals/construction.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbnN0cnVjdGlvbi5weQ==) | `95.95% <0%> (-0.8%)` | :arrow_down: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `90.72% <0%> (-0.34%)` | :arrow_down: |
| [pandas/core/arrays/sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3NwYXJzZS5weQ==) | `94.19% <0%> (-0.31%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.82% <0%> (-0.2%)` | :arrow_down: |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `97.17% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.34% <0%> (-0.13%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.89% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.84% <0%> (-0.11%)` | :arrow_down: |
| ... and [23 more](https://codecov.io/gh/pandas-dev/pandas/pull/27050/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27050?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/27050?src=pr&el=footer). Last update [45ea267...0618be6](https://codecov.io/gh/pandas-dev/pandas/pull/27050?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Would prefer that piece as follow up. I have somewhat of a concern that that might not actually the be correct solution as it is not suggested by MyPy (refs like that only suggested within one module). It might just be replacing those with Any

I could be wrong but would like more time to investigate
lgtm. @jorisvandenbossche any comments?
Yea that’s correct - something we don’t control going forward

Sent from my iPhone

> On Jun 30, 2019, at 1:11 AM, topper-123 <notifications@github.com> wrote:
> 
> @topper-123 commented on this pull request.
> 
> In doc/source/development/contributing.rst:
> 
> > +
> +   from typing import Optional
> +
> +   maybe_primes = []  # type: Optional[int]
> +
> +If a function accepts multiple arguments, every parameter should appear on a separate line. So rather than
> +
> +.. code-block:: python
> +
> +   def some_func(a: str, b: float, c: Union[int, float]) -> float:
> +
> +The preferred style would be
> +
> +.. code-block:: python
> +
> +   def some_func(a: str,
> I'm +1 on requiring multiline defs to be wrapped in the style guide. It makes for much clearer code.
> 
> OTOH, if we go with Black, such choices will be made for us?
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub, or mute the thread.

@jorisvandenbossche do you have any other edits you want to make to this? Would like to get this in dev guide for users to see
Ping @jorisvandenbossche
Let's merge this today and do the rest as followups? I suspect this is an improvement from master.
Merging as is from last comment. Anything else here can be done as follow ups
Thanks @WillAyd