-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refactor main NextCloud object to not dynamically assign methods #42
Comments
@jasongi Thank you for raising this issue! |
@matejak @jasongi Yes, probably reason for dynamically methods assignment was to "protect" some internal methods, it was like this before we started working on it. |
Great, so @jasongi there is nothing stopping you from creating a pull request that fixes this! |
Note : usage of |
If IntelliSense is somehow intelligent, then it shall at least initialize the Class. Try the following trick in NextCloud.py. import six
class MetaClient(type):
def __new__(meta, name, bases, attrs):
cls = type.__new__(meta, name, bases, attrs)
for functionality_class in API_WRAPPER_CLASSES:
for potential_method in dir(functionality_class):
if not (
potential_method.isupper() or
potential_method.startswith('_')
):
if not callable(getattr(functionality_class, potential_method)):
pass
else:
setattr(cls, potential_method, getattr(
functionality_class, potential_method))
return cls
class NextCloud(object, six.with_metaclass(MetaClient)):
.... |
Note : Using "private" functions with underscore is just a way to avoid code repetition. |
I wouldn't use an IDE that executed code without me asking it to - I doubt any of them do. |
Sphinx (doc builder) do it. In Python , it happens to have docstring dynamically computed. Check that, and change your IDE if it does works. |
VS Code is the most used IDE on the planet. I don't think I'll be changing my IDE because of a library I was using two years ago abuses language features to generate classes that don't support statically analysing the functions. |
This project has helped me out a lot, however the current way the main object is set out makes it hard to develop. This is because the methods are dynamically allocated to the main class, meaning you can't use IntelliSense to view methods (see screenshot).
It seems like a possible solution would be to refactor the classes as regular mixins and inherit from them. It also looks like the dynamic setup was also done to stop people using "private" functions with underscore in front of them - I don't think this is really required as python tends to follow the "We're all responsible users" principle.
I'm happy to work on a PR if this is agreeable?
The text was updated successfully, but these errors were encountered: