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

feat(#4): collect all errors #5

Merged
merged 2 commits into from Sep 24, 2022
Merged

feat(#4): collect all errors #5

merged 2 commits into from Sep 24, 2022

Conversation

KyleKing
Copy link
Contributor

Fixes #4

Adds feature and tests for printing multiple errors are once

> python tests/multiple_incorrect_methods_test.py
Traceback (most recent call last):
  File "/Users/kyleking/Developer/Pull_Requests/abcmeta/tests/multiple_incorrect_methods_test.py", line 27, in <module>
    class ABCDerived(ABCParent):
  File "/Users/kyleking/.asdf/installs/python/3.10.5/lib/python3.10/abc.py", line 106, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
  File "/Users/kyleking/.asdf/installs/python/3.10.5/lib/python3.10/site-packages/abcmeta/__init__.py", line 192, in __init_subclass__
    raise AttributeError("\n\n".join(errors))
AttributeError: Derived class 'ABCDerived' has not implemented 'method_1' method of the parent class 'ABCParent'.

Signature of the derived method is not the same as parent class:
- method_2(self, name: str, age: int) -> Dict[str, str]
?                      ^ -

+ method_2(self, name: int, age: int) -> Dict[str, str]
?                      ^^

Derived method expected to get 'name:<class 'str'>' paramter's type, but gets 'name:<class 'int'>'

Signature of the derived method is not the same as parent class:
- method_4(self, name: str, age: int) -> Tuple[str, str]
?                ^  ^

+ method_4(self, family: str, age: int) -> Tuple[str, str]
?                ^  ^^^

Derived method expected to get 'name' paramter, but gets 'family'

Only downside is that maybe the join on 2x \n could be more clear. Should it be something involving dashes like '-' * 80 or 3x \n?

@mortymacs
Copy link
Owner

Thanks!
You're PR is very good. Do you mind if I add a commit to your PR? I just wanna add one more method to the new test file and also rename the new test file into the incorrect_multiple_methods_test.py.

@KyleKing
Copy link
Contributor Author

Yeah, no problem! Feel free to make any changes and merge when you're happy with it

@mortymacs
Copy link
Owner

Let's merge your PR and then I'll send a separate PR as it will contain the error number.

@mortymacs mortymacs merged commit fea1e5e into mortymacs:main Sep 24, 2022
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.

PR: Catch Multiple Errors
2 participants