Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix private method call issue in TypeChecker
  • Loading branch information
densmirn committed Mar 25, 2020
commit aa8b017b928e31b1dd54bc3fa507f5cc252c4b31
4 changes: 2 additions & 2 deletions sdc/utilities/sdc_typing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def raise_exc(self, data, expected_types, name='', exc_cls=TypingError):
exc_cls: :obj:`Exception`
class of the exception to be raised
"""
self._raise_exc(self, exc_cls, self.default_tmpl, self.func_name,
self._raise_exc(exc_cls, self.default_tmpl, self.func_name,
name, data, expected_types)

def raise_unsupported_exc(self, data, name='', exc_cls=SDCLimitation):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking of replacing all raises related to SDC limitations with this, but it seems this only covers case of unsupported parameters, so for instance in series.fillna we have:

            raise TypingError('{} Not implemented when Series dtype is {} and\
                 inplace={}'.format(_func_name, self.dtype, inplace))

Maybe add in raise_exc and internal func additional parameter e.g. msg, which if exists will be used instead of default msg format?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to replace call

msg = '{} Not implemented when Series dtype is {} and inplace={}'.format(_func_name, self.dtype, inplace)
raise SDCLimitation(msg)

with something like this

msg = '{} Not implemented when Series dtype is {} and inplace={}'.format(_func_name, self.dtype, inplace)
ty_checker.raise_exc(None, None, exc_cls=SDCLimitation, msg=msg)

?

I think TypeChecker shouldn't be used for such complicated cases, TypeChecker doesn't make sense, when it increases the amount of code and makes it harder.
Maybe I didn't catch you correctly, please correct me in this case.

Expand All @@ -108,7 +108,7 @@ def raise_unsupported_exc(self, data, name='', exc_cls=SDCLimitation):
class of the exception to be raised
"""
tmpl = '{} Unsupported object {}\n given: {}'
self._raise_exc(self, exc_cls, tmpl, self.func_name, name, data)
self._raise_exc(exc_cls, tmpl, self.func_name, name, data)

def check(self, data, accepted_type, name=''):
"""
Expand Down