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
Adds Is alternate, shorter API #14
Conversation
One other note, this adds a is(n).not_none.float.nonzero It'll say your variable expression has no effect. So if people want, they can discourage the linter with: is(n).not_none.float.nonzero.finish()
|
I see our approach here as being possibly cross-breed. So I think we might not need finish. We could possibly set it up like This way we get the best of both sides. We somehow need a great documentation for all these though. |
I just realised this still doesn't fix the issue of the linter complaint. |
Cool @mikeckennedy ! Here are my 4 points:
Thank you very much! |
Thanks, will do. Just found a clever way to avoid the linter issues, see the latest commit just above. |
As I make changes to the docs, do you want the shorter |
As you like it! |
Hi @csparpa I think the PR is ready. Can you let me know if you agree? |
Note: I uncovered some bugs while at it. For example, there are no tests for XML in the Check API and if I try to test it, I get this: # Test code
def test_is_xml_fail(self):
obj = "not xml"
with self.assertRaises(CheckError):
Is(obj).xml Results in this failing! with the error:
Rather than succeeding by throwing a But it's not relevant to this PR as we are just extending Check and it's Check that's busted here. Same for YAML and other things like Have a look at |
Perfect job! Thanks!!! |
Thanks @csparpa Happy to give this back to this project. As for being a full contributor, maybe, but not yet. Let me add a little more and if I keep at it, I'm happy to be given more status there. |
Also, just to be clear, the failing tests are features I started adding because I saw them in the documentation but not the |
Finally, can you let me know when the new version is on PyPI so I can try the changes in this PR on a few projects? |
No probs, I've fixed the broken tests. |
Hi @csparpa That latest change you made to drop all the actual properties and methods from Here it is on my branch: And here it is with this "improvement": Please, please, please put it back? It won't work with mypy, it fails with pycharm and vs code, etc etc. |
It's on PyPI :-( Sorry about it! @mikeckennedy don't want to bother you too much but.. Can you investigate if IDEs code completion can work properly with the splitted code structure? I want reverting to be the very last resort |
I think you can make it work super easy but you'll just have to create the Is class differently. Rather than being super dynamic, just make a set of subclasses in the assersions. So for example: class __IsDictAsserts:
def dict(check_obj) -> "Is":
# noinspection PyUnresolvedReferences
Check(check_obj.object).is_dict()
return check_obj
def not_dict(check_obj) -> "Is":
# noinspection PyUnresolvedReferences
Check(check_obj.object).is_not_dict()
return check_obj
# ...
class __IsStringsAssert:
# .... Then create Is as:
That will give you type checking, IDE support, code navigation, etc, without a huge class. What do you think? BTW, you should also do this for |
Hi guys. This is in response to issue #12 . Let me know what you think. I tried to stick mostly to the syntax of
Check()
but in a few places slight rephrasing seemed better. One example of that is going fromCheck(obj).is_not_zero()
->Is(obj).nonzero
as that's the common mathematical term for that check.