Skip to content

REF: move registry, Registry to dtypes.base #34830

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 12 commits into from
Jul 10, 2020

Conversation

jbrockmendel
Copy link
Member

These are more closely related to ExtensionDtype than to our internal EADtypes. More concretely, they are low-dependency, while dtypes.dtypes has some unfortunate circular dependencies.

I'd also like to move pandas_dtype and is_dtype_equal from dtypes.common so that those can be stricty "above" dtypes.dtypes in the dependency structure. Saving that for another pass.

@WillAyd
Copy link
Member

WillAyd commented Jun 19, 2020

no objections from me - @TomAugspurger thoughts?

@WillAyd WillAyd added the Refactor Internal refactoring of code label Jun 19, 2020
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Yeah, sounds reasonable. Light suggestion to move it to it's own module to avoid moving things twice, but either way works. Merge whenever.

@@ -352,3 +352,92 @@ def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]:
return self
else:
return None


def register_extension_dtype(cls: Type[ExtensionDtype]) -> Type[ExtensionDtype]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even their own file?

Right now it might not merit its own file, but in the future I could see us having an entrypoints-based registry, which will add more lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah i agree, let's create registry.py

@TomAugspurger
Copy link
Contributor

Hmm doctests failure may be related though.

@jbrockmendel
Copy link
Member Author

I see how the doctest is failing, but its not at all clear why it isnt failing in master

@WillAyd
Copy link
Member

WillAyd commented Jun 19, 2020

I couldn't seem to reproduce that error locally. Looks like the assertion was added back in #30619 to close a mypy issue - @simonjayhawkins any idea?

@@ -352,3 +352,92 @@ def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]:
return self
else:
return None


def register_extension_dtype(cls: Type[ExtensionDtype]) -> Type[ExtensionDtype]:
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah i agree, let's create registry.py

@jreback jreback added the Dtype Conversions Unexpected or buggy dtype conversions label Jun 20, 2020
@jbrockmendel
Copy link
Member Author

yeah i agree, let's create registry.py

hmm not sure about this, since the other two funcs im interested in (pandas_dtype and is_dtype_equal) depend on registry, so not sure where those would go.

but its a moot point until i figure out the doctest thing, which im getting nowhere on

@simonjayhawkins
Copy link
Member

I couldn't seem to reproduce that error locally. Looks like the assertion was added back in #30619 to close a mypy issue - @simonjayhawkins any idea?

I think the comments in #30619 explain the reasoning. Could either sort out the class hierarchy so that Liskov is obeyed (maybe add something like a _basename class attribute to access from the construct_from_string classmethod) or simply change the assert to a cast or #type: ignore for now.

@jreback jreback added this to the 1.1 milestone Jul 10, 2020
@jreback
Copy link
Contributor

jreback commented Jul 10, 2020

lgtm ping on green

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit 4fc4622 into pandas-dev:master Jul 10, 2020
@jbrockmendel jbrockmendel deleted the ref-dtypes branch July 11, 2020 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants