-
Notifications
You must be signed in to change notification settings - Fork 670
chore: explicitly import gitlab.v4.objects/cli #1310
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1310 +/- ##
==========================================
- Coverage 80.76% 80.72% -0.04%
==========================================
Files 69 69
Lines 3623 3627 +4
==========================================
+ Hits 2926 2928 +2
- Misses 697 699 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have 1 comment, currently we still dynamically import in the cli module:
Line 184 in 5cc60d5
cli_module = importlib.import_module("gitlab.v%s.cli" % config.api_version) |
So IMO I'd change that too for consistency.
From a quick grep there's also this, might only be an issue later though, with objects:
Line 62 in 5cc60d5
self.__dict__["_module"] = importlib.import_module(module_name) |
Otherwise, this also helps by not confusing tools like pyinstaller/cx_freeze with dynamic imports so you don't need hooks for standalone executables. And according to https://docs.gitlab.com/ee/api/,
GraphQL co-exists with the current v4 REST API. If we have a v5 API, this should be a compatibility layer on top of GraphQL.
So this makes sense to me, one if/elif block at some point in the future shouldn't hurt, people do it all the time for OS-dependent imports 😄 /cc @max-wittig
Done.
I'm not quite sure what to do there 😟 |
As we only support the v4 Gitlab API, explicitly import gitlab.v4.objects and gitlab.v4.clie instead of dynamically importing it depending on the API version. This has the added benefit of mypy being able to type check the Gitlab __init__() function as currently it will fail if we enable type checking of __init__() it will fail. Also, this also helps by not confusing tools like pyinstaller/cx_freeze with dynamic imports so you don't need hooks for standalone executables. And according to https://docs.gitlab.com/ee/api/, "GraphQL co-exists with the current v4 REST API. If we have a v5 API, this should be a compatibility layer on top of GraphQL."
As we only support the v4 Gitlab API, explicitly import
gitlab.v4.objects instead of dynamically importing it depending on the
API version.
This has the added benefit of mypy being able to type check the Gitlab
init() function as currently it will fail if we enable type
checking of init() it will fail.