summaryrefslogtreecommitdiff
path: root/gitlab/v4/cli.py
Commit message (Collapse)AuthorAgeFilesLines
* fix(cli): handle list response for json/yaml outputJohn L. Villalovos2022-10-061-4/+4
| | | | | | | | | Handle the case with the CLI where a list response is returned from GitLab and json/yaml output is requested. Add a functional CLI test to validate it works. Closes: #2287
* chore: consolidate license and authorsNejc Habjan2022-08-041-18/+0
|
* chore: enable mypy check `disallow_any_generics`John L. Villalovos2022-08-011-5/+17
|
* feat(cli): add a custom help formatterWaldek Maleska2022-07-281-1/+3
| | | | | | | | | | Add a custom argparse help formatter that overrides the output format to list items vertically. The formatter is derived from argparse.HelpFormatter with minimal changes. Co-authored-by: John Villalovos <john@sodarock.com> Co-authored-by: Nejc Habjan <nejc.habjan@siemens.com>
* fix: add `get_all` param (and `--get-all`) to allow passing `all` to APINejc Habjan2022-07-211-1/+12
|
* feat: support validating CI lint resultsNejc Habjan2022-07-091-0/+11
|
* test(pylint): enable pylint "unused-argument" checkJohn L. Villalovos2022-06-261-5/+5
| | | | | | | | | | Enable the pylint "unused-argument" check and resolve issues it found. * Quite a few functions were accepting `**kwargs` but not then passing them on through to the next level. Now pass `**kwargs` to next level. * Other functions had no reason to accept `**kwargs`, so remove it * And a few other fixes.
* feat(downloads): allow streaming downloads access to response iterator (#1956)Tom Catshoek2022-06-261-0/+1
| | | | | | | | | | | | | | | * feat(downloads): allow streaming downloads access to response iterator Allow access to the underlying response iterator when downloading in streaming mode by specifying `iterator=True`. Update type annotations to support this change. * docs(api-docs): add iterator example to artifact download Document the usage of the `iterator=True` option when downloading artifacts * test(packages): add tests for streaming downloads
* chore(cli): rename "object" to "GitLab resource"John L. Villalovos2022-06-051-1/+3
| | | | | Make the parser name more user friendly by renaming from generic "object" to "GitLab resource"
* Merge pull request #2051 from python-gitlab/jlvillal/more_more_pylintNejc Habjan2022-06-051-4/+6
|\ | | | | chore: enable more pylint checks
| * chore: enable pylint check: "no-self-use"John L. Villalovos2022-06-041-4/+6
| | | | | | | | Enable the pylint check "no-self-use" and fix the errors detected.
* | chore: rename `whaction` and `action` to `resource_action` in CLIJohn L. Villalovos2022-06-051-10/+21
|/ | | | | Rename the variables `whaction` and `action` to `resource_action` to improve code-readability.
* Merge pull request #2053 from python-gitlab/jlvillal/resourceNejc Habjan2022-06-041-9/+9
|\ | | | | chore: rename `what` to `gitlab_resource`
| * chore: rename `what` to `gitlab_resource`John L. Villalovos2022-06-031-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | Naming a variable `what` makes it difficult to understand what it is used for. Rename it to `gitlab_resource` as that is what is being stored. The Gitlab documentation talks about them being resources: https://docs.gitlab.com/ee/api/api_resources.html This will improve code readability.
* | Merge pull request #2052 from python-gitlab/jlvillal/cli_minor_cleanNejc Habjan2022-06-041-2/+2
|\ \ | |/ | | chore: rename `__call__()` to `run()` in GitlabCLI
| * chore: rename `__call__()` to `run()` in GitlabCLIJohn L. Villalovos2022-06-031-2/+2
| | | | | | | | Less confusing to have it be a normal method.
* | chore: enable 'consider-using-sys-exit' pylint checkJohn L. Villalovos2022-06-031-2/+2
|/ | | | | Enable the 'consider-using-sys-exit' pylint check and fix errors raised.
* chore(cli): ignore coverage on exceptions triggering cli.dieNejc Habjan2022-06-011-7/+7
|
* fix(cli): fix project export download for CLINejc Habjan2022-06-011-1/+1
| | | | | Since ac1c619cae6481833f5df91862624bf0380fef67 we delete parent arg keys from the args dict so this has been trying to access the wrong attribute.
* fix: duplicate subparsers being added to argparseJohn L. Villalovos2022-05-091-7/+18
| | | | | | | | | | Python 3.11 added an additional check in the argparse libary which detected duplicate subparsers being added. We had duplicate subparsers being added. Make sure we don't add duplicate subparsers. Closes: #2015
* feat: display human-readable attribute in `repr()` if presentNejc Habjan2022-05-081-3/+3
|
* fix(cli): make 'per_page' and 'page' type explicitThomas de Grenier de Latour2022-01-251-2/+2
|
* chore: remove old-style classesNejc Habjan2022-01-231-4/+4
|
* fix(cli): allow custom methods in managersNejc Habjan2022-01-221-4/+6
|
* chore: replace usage of utils._url_encode() with utils.EncodedId()jlvillal/encoded_idJohn L. Villalovos2022-01-131-1/+1
| | | | | | utils.EncodedId() has basically the same functionalityy of using utils._url_encode(). So remove utils._url_encode() as we don't need it.
* fix: remove custom URL encodingJohn L. Villalovos2022-01-081-1/+1
| | | | | | | | | | We were using `str.replace()` calls to take care of URL encoding issues. Switch them to use our `utils._url_encode()` function which itself uses `urllib.parse.quote()` Closes: #1356
* fix(cli): url-encode path components of the URLJohn L. Villalovos2022-01-081-2/+18
| | | | | | | | | | | | | In the CLI we need to make sure the components put into the path portion of the URL are url-encoded. Otherwise they will be interpreted as part of the path. For example can specify the project ID as a path, but in the URL it must be url-encoded or it doesn't work. Also stop adding the components of the path as query parameters in the URL. Closes: #783 Closes: #1498
* chore: fix pylint error "expression-not-assigned"John L. Villalovos2021-12-071-28/+20
| | | | | | | | Fix pylint error "expression-not-assigned" and remove check from the disabled list. And I personally think it is much more readable now and is less lines of code.
* refactor: use new-style formatting for named placeholdersNejc Habjan2021-11-081-1/+1
|
* chore: enforce type-hints on most files in gitlab/v4/objects/jlvillal/mypy_small_files_1John L. Villalovos2021-11-081-0/+2
| | | | | | | * Add type-hints to some of the files in gitlab/v4/objects/ * Fix issues detected when adding type-hints * Changed mypy exclusion to explicitly list the 13 files that have not yet had type-hints added.
* refactor: use f-strings for string formattingNejc Habjan2021-11-051-30/+30
|
* chore: improve type-hinting for managersJohn L. Villalovos2021-09-071-1/+4
| | | | | | | | | | | | | | | The 'managers' are dynamically created. This unfortunately means that we don't have any type-hints for them and so editors which understand type-hints won't know that they are valid attributes. * Add the type-hints for the managers we define. * Add a unit test that makes sure that the type-hints and the '_managers' attribute are kept in sync with each other. * Add unit test that makes sure specified managers in '_managers' have a name ending in 'Managers' to keep with current convention. * Make RESTObject._managers always present with a default value of None. * Fix a type-issue revealed now that mypy knows what the type is
* chore: add type-hints to gitlab/v4/cli.pyJohn L. Villalovos2021-05-311-39/+120
| | | | | | * Add type-hints to gitlab/v4/cli.py * Add required type-hints to other files based on adding type-hints to gitlab/v4/cli.py
* chore: use built-in function issubclass() instead of getmro()John L. Villalovos2021-05-281-12/+10
| | | | | | | Code was using inspect.getmro() to replicate the functionality of the built-in function issubclass() Switch to using issubclass()
* chore: fix import ordering using isortJohn L. Villalovos2021-05-251-1/+1
| | | | | | Fix the import ordering using isort. https://pycqa.github.io/isort/
* fix(cli): fix parsing CLI objects to classnamesNejc Habjan2021-05-151-2/+2
|
* Merge pull request #1412 from JohnVillalovos/jlvillal/optional_get_attrsNejc Habjan2021-04-261-7/+4
|\ | | | | chore: make Get.*Mixin._optional_get_attrs always present
| * chore: make Get.*Mixin._optional_get_attrs always presentJohn L. Villalovos2021-04-241-7/+4
| | | | | | | | | | | | | | | | Always create GetMixin/GetWithoutIdMixin._optional_get_attrs attribute with a default value of tuple() This way we don't need to use hasattr() and we will know the type of the attribute.
* | Merge pull request #1411 from JohnVillalovos/jlvillal/list_filtersMax Wittig2021-04-251-7/+4
|\ \ | | | | | | chore: make ListMixin._list_filters always present
| * | chore: make ListMixin._list_filters always presentJohn L. Villalovos2021-04-241-7/+4
| |/ | | | | | | | | | | | | | | Always create ListMixin._list_filters attribute with a default value of tuple(). This way we don't need to use hasattr() and we will know the type of the attribute.
* | chore: make RESTObject._short_print_attrs always presentJohn L. Villalovos2021-04-241-1/+1
|/ | | | | | | | Always create RESTObject._short_print_attrs with a default value of None. This way we don't need to use hasattr() and we will know the type of the attribute.
* chore: have _create_attrs & _update_attrs be a namedtupleJohn L. Villalovos2021-04-171-4/+4
| | | | | | Convert _create_attrs and _update_attrs to use a NamedTuple (RequiredOptional) to help with code readability. Update all code to use the NamedTuple.
* chore: add _create_attrs & _update_attrs to RESTManagerJohn L. Villalovos2021-03-101-23/+12
| | | | | | | Add the attributes: _create_attrs and _update_attrs to the RESTManager class. This is so that we stop using getattr() if we don't need to. This also helps with type-hints being available for these attributes.
* fix: checking if RESTManager._from_parent_attrs is setJohn L. Villalovos2021-03-071-13/+7
| | | | | | | | | | | | Prior to commit 3727cbd21fc40b312573ca8da56e0f6cf9577d08 RESTManager._from_parent_attrs did not exist unless it was explicitly set. But commit 3727cbd21fc40b312573ca8da56e0f6cf9577d08 set it to a default value of {}. So the checks using hasattr() were no longer valid. Update the checks to check if RESTManager._from_parent_attrs has a value.
* chore: make _types always present in RESTManagerJohn L. Villalovos2021-03-071-3/+2
| | | | | | | | | | We now create _types = {} in RESTManager class. By making _types always present in RESTManager it makes the code simpler. We no longer have to do: types = getattr(self, "_types", {}) And the type checker now understands the type.
* fix(cli): write binary data to stdout bufferNejc Habjan2020-10-121-0/+2
|
* chore(cli): remove python2 codeNejc Habjan2020-10-121-5/+1
|
* chore: remove remnants of python2 importsNejc Habjan2020-08-221-1/+0
|
* refactor: remove six dependencyMax Wittig2019-12-181-4/+2
|
* fix(cli): don't fail when the short print attr value is Nonexarx002019-07-211-2/+2
| | | | | Fixes #717 Fixes #727