Avoid accessing private loc methods
State: closed

Works toward fixing #27344 

Adds types where unambiguous

Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Clean

Comments:
@WillAyd can you help me make heads or tails out of the mypy complaint?
Yea I imagine it's because of part of Line 1745:

```python
[key] + [slice(None)]
```

So the left operand is inferred to `List[str]` while the right hand side is a `slice` and Mypy is complaining that you are appending a slice to a list of what maybe should be just str.

Could either:

1. Create a new variable for this typed to `List[Union[str, slice]]`
2. \# type: ignore this line

I think option 1 is better since this code is shadowing `key` variable anyway with a different type
> Yea I imagine it's because of part of Line 1745:

The part that I don't get is why is it only complaining now?  The types being added should be a strict improvement typing-wise, right?
Haven’t reviewed in detail but if first annotations in module Mypy will actually start checking. Before may have just skipped

Sent from my iPhone

> On Jul 14, 2019, at 8:50 AM, jbrockmendel <notifications@github.com> wrote:
> 
> Yea I imagine it's because of part of Line 1745:
> 
> The part that I don't get is why is it only complaining now? The types being added should be a strict improvement typing-wise, right?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

Hello @jbrockmendel! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:







There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-07-23 23:08:04 UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27383?src=pr&el=h1) Report
> Merging [#27383](https://codecov.io/gh/pandas-dev/pandas/pull/27383?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c104a0c9ce4c1dd0d63df121f0fa50657b6d6447?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #27383      +/-   ##
==========================================
- Coverage   92.91%   92.89%   -0.02%     
==========================================
  Files         184      184              
  Lines       50385    50387       +2     
==========================================
- Hits        46813    46809       -4     
- Misses       3572     3578       +6
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `91.57% <90.47%> (-0.01%)` | :arrow_down: |
| #single | `42.33% <90.47%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27383?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.34% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.08% <100%> (-0.12%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `94.72% <100%> (+0.1%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/util/\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlY29yYXRvcnMucHk=) | `92.13% <0%> (-3.22%)` | :arrow_down: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `87.65% <0%> (ø)` | :arrow_up: |
| [pandas/io/sas/sasreader.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNyZWFkZXIucHk=) | `96% <0%> (ø)` | :arrow_up: |
| [pandas/io/excel/\_base.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsL19iYXNlLnB5) | `92% <0%> (ø)` | :arrow_up: |
| [pandas/io/feather\_format.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2ZlYXRoZXJfZm9ybWF0LnB5) | `25% <0%> (ø)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27383?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/27383?src=pr&el=footer). Last update [c104a0c...f9c7fc9](https://codecov.io/gh/pandas-dev/pandas/pull/27383?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/27383?src=pr&el=h1) Report
> Merging [#27383](https://codecov.io/gh/pandas-dev/pandas/pull/27383?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c104a0c9ce4c1dd0d63df121f0fa50657b6d6447?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #27383      +/-   ##
==========================================
- Coverage   92.91%   92.89%   -0.02%     
==========================================
  Files         184      184              
  Lines       50385    50387       +2     
==========================================
- Hits        46813    46809       -4     
- Misses       3572     3578       +6
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `91.57% <90.47%> (-0.01%)` | :arrow_down: |
| #single | `42.33% <90.47%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27383?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.34% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.08% <100%> (-0.12%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `94.72% <100%> (+0.1%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/util/\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlY29yYXRvcnMucHk=) | `92.13% <0%> (-3.22%)` | :arrow_down: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `87.65% <0%> (ø)` | :arrow_up: |
| [pandas/io/sas/sasreader.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNyZWFkZXIucHk=) | `96% <0%> (ø)` | :arrow_up: |
| [pandas/io/excel/\_base.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsL19iYXNlLnB5) | `92% <0%> (ø)` | :arrow_up: |
| [pandas/io/feather\_format.py](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2ZlYXRoZXJfZm9ybWF0LnB5) | `25% <0%> (ø)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/pandas-dev/pandas/pull/27383/diff?src=pr&el=tree-more) | |

------

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

gentle ping; there are (requested) follow-ups
thanks