EastAgile / robber.py

BDD / TDD assertion library for Python
MIT License
8 stars 1 forks source link

Enable code_completion for robber.py #21

Open hotay opened 7 years ago

hotay commented 7 years ago

Issue

It's just a thing to consider but since we are using magic for robber.py, there's no code completion engine could understand this. So, we might need to consider this, if we can, this is a strong plus point to robber.py. Anyway, it would be a hard one, then, just consider.

tklarryonline commented 7 years ago

I agree that this should be considered much later since it's not that huge need. Despite PyCharm, I believe the code completion engine like Vim's YouCompleteMe could cope with this.

hieueastagile commented 7 years ago

@tklarryonline No, actually, if we still use magic in robber.py, YCM could not understand it too (we are using it so we can make sure :D). Anyway, I'm agree that it should be considered later.

tklarryonline commented 7 years ago

Oh really 😐. I thought YCM uses word-matching to suggest us the next possible use case...

hieueastagile commented 7 years ago

I can say that it's more intelligent than what pyCharm can do :P.

hieueastagile commented 7 years ago

Last update:

So, let's do a quick summary for this issue:

catriuspham commented 7 years ago

I cannot get Pycharm, Atom with Jedi, Sublime with Anacoda and Jedi to autocomplete robber.py. So I come up with an easier solution: we create a class named ExpectTemplate, then we inherit expect from it. The code will look like this:

class ExpectTemplate:
    @staticmethod
    def eq(expected):
        """
        :param expected:
        :return:
        """
        pass

class expect(ExpectTemplate):
    ...

This is what I get in Pycharm image

The benefit of this method is that we can freely show the args/kwargs that the user need to provide. @hieueastagile What do you think?

hieueastagile commented 7 years ago

It seems hacky/workaround, huh?

catriuspham commented 7 years ago

Not really, it's like we predefine a class with an outline, then override it later.

hieueastagile commented 7 years ago

@catriuspham Honestly, I don't like it :D. ExpectTemplate might not be synced with what we register to expect, so it's considered a code smell.

catriuspham commented 7 years ago

@hieueastagile I gonna research more, though :stuck_out_tongue:

hieueastagile commented 7 years ago

wait to see your good news @catriuspham

hieueastagile commented 6 years ago

@catriuspham After a year, I found a way to do that :))): https://amir.rachum.com/blog/2016/10/05/python-dynamic-attributes/

toantran-ea commented 6 years ago

💯

tklarryonline commented 6 years ago

Why we didn't think of __dir__ in the first place :))))

catriuspham commented 6 years ago

Is this the real life? Is this just fantasy?

hieueastagile commented 6 years ago

:)))). Don't you mind to implement it @tklarryonline @catriuspham :))?