Skip to content

TYP: clean for PY3.8 (final) #42422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 14, 2021
Merged

Conversation

simonjayhawkins
Copy link
Member

No description provided.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Jul 7, 2021
@@ -50,10 +50,12 @@ class SharedBlock:

class NumpyBlock(SharedBlock):
values: np.ndarray
# @final # not useful in cython, but we _would_ annotate with @final
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbrockmendel i've moved the comment from the cython since the final decorator could be added to the stub so the comment is not relevant.

However, we can't add to the stub as it is overridden in subclass in pandas/core/internals/blocks.py

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like it is inaccurate so should be removed anyway

@@ -1661,7 +1661,7 @@ def _unstack(self, unstacker, fill_value, new_placement):
class NumpyBlock(libinternals.NumpyBlock, Block):
values: np.ndarray

getitem_block_index = libinternals.NumpyBlock.getitem_block_index
getitem_block_index = final(libinternals.NumpyBlock.getitem_block_index)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbrockmendel why is the override needed? is this a cython class thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this was to make mypy happy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mypy errors are...

pandas/core/internals/blocks.py:1661: error: Definition of "getitem_block_index" in base class "NumpyBlock" is incompatible with definition in base class "Block"  [misc]
pandas/core/internals/blocks.py:1670: error: Definition of "getitem_block_index" in base class "NDArrayBackedBlock" is incompatible with definition in base class "Block"  [misc]
Found 2 errors in 1 file (checked 1299 source files)

they aren't needed. fixed up mypy error by moving remaining Python implementation of getitem_block_index from Block to ExtensionBlock and added @final to stub instead.

Also added @final to Python implementation of getitem_block_index for consistency.

Callable,
final,
)
from pandas._typing import Callable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks iffy. we look at this independently and see if this occurs elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this get resolved? if so, LGTM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened #42498

@jreback jreback added this to the 1.4 milestone Jul 12, 2021
@jreback
Copy link
Contributor

jreback commented Jul 12, 2021

can you rebase

@jreback jreback merged commit 949592a into pandas-dev:master Jul 14, 2021
@simonjayhawkins simonjayhawkins deleted the typing-38-2 branch July 19, 2021 13:56
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants