Skip to content
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

late decoration #73

Closed
wants to merge 3 commits into from
Closed

late decoration #73

wants to merge 3 commits into from

Conversation

obeleh
Copy link

@obeleh obeleh commented Jul 27, 2018

added late decorating for forward references that refer to a class that is being constructed

the corresponding issue is #72

@obeleh
Copy link
Author

obeleh commented Jul 27, 2018

The build fails because the dev branch already fails with this stacktrace:

Error
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run
    testMethod()
  File "/Users/sjuul/workspace/enforce/tests/enforce_tests/test_iterable_types.py", line 27, in test_iterator
    foo(ai)
  File "/Users/sjuul/workspace/enforce/enforce/decorators.py", line 117, in universal
    _args, _kwargs, _ = enforcer.validate_inputs(parameters)
  File "/Users/sjuul/workspace/enforce/enforce/enforcers.py", line 97, in validate_inputs
    process_errors(self.settings, self.validator.errors, self.hints)
  File "/Users/sjuul/workspace/enforce/enforce/enforcers.py", line 288, in process_errors
    processor(parser, exception, errors, hints, is_return_type)
  File "/Users/sjuul/workspace/enforce/enforce/exceptions.py", line 32, in process_errors
    raise_errors(exception, message)
  File "/Users/sjuul/workspace/enforce/enforce/exceptions.py", line 27, in raise_errors
    raise exception(message)
enforce.exceptions.RuntimeTypeError: 
  The following runtime type errors were encountered:
       Argument 'i' was not of type typing.Iterator[int]. Actual type was range_iterator.

('(Assertion) Field Guard for: typing.Union[typing.Dict[str, typing.Union[int, '
 'typing.List[int], NoneType]], typing.List[typing.Tuple[str, int]]]')
typing.Callable[..., NoneType]
SubTest failure: Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 523, in subTest
    yield
  File "/Users/sjuul/workspace/enforce/tests/test_protocol.py", line 134, in test_parent
    self.assertEqual(str(fields[k]), v)
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/teamcity/diff_tools.py", line 39, in _patched_equals
    raise native_error
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/teamcity/diff_tools.py", line 32, in _patched_equals
    old(self, first, second, msg)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 829, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 1203, in assertMultiLineEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 670, in fail
    raise self.failureException(msg)
AssertionError: '(Assertion) Field Guard for: typing.Callable[[str], str]' != '(Assertion) Field Guard for: typing.Callable[[typing.Type[~T], str], str]'
- (Assertion) Field Guard for: typing.Callable[[str], str]
+ (Assertion) Field Guard for: typing.Callable[[typing.Type[~T], str], str]
?                                               +++++++++++++++++



One or more subtests failed
Failed subtests list: (k='bar')


Ran 115 tests in 14.262s

FAILED (failures=1, errors=1, skipped=1)

@obeleh
Copy link
Author

obeleh commented Jul 27, 2018

I've found a few other cases that should be fixed as well. Hang on.

@obeleh
Copy link
Author

obeleh commented Jul 27, 2018

Also implemented using forward refs in parameters. And noticed that I added an extra frame to the stack when doing the late decorating. So I made the stack depth available as a parameter to get_universal_decorator

@obeleh obeleh closed this Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant