summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
Commit message (Collapse)AuthorAgeFilesLines
* chore: consolidate license and authorsNejc Habjan2022-08-041-17/+0
|
* chore: enable mypy check `disallow_any_generics`John L. Villalovos2022-08-011-2/+2
|
* chore: enable mypy check `warn_return_any`John L. Villalovos2022-07-281-1/+4
| | | | Update code so that the `warn_return_any` check passes.
* fix: use the [] after key names for array variables in `params`John L. Villalovos2022-07-271-3/+12
| | | | | | | | | | | | | | | | | | 1. If a value is of type ArrayAttribute then append '[]' to the name of the value for query parameters (`params`). This is step 3 in a series of steps of our goal to add full support for the GitLab API data types[1]: * array * hash * array of hashes Step one was: commit 5127b1594c00c7364e9af15e42d2e2f2d909449b Step two was: commit a57334f1930752c70ea15847a39324fa94042460 Fixes: #1698 [1] https://docs.gitlab.com/ee/api/#encoding-api-parameters-of-array-and-hash-types
* chore: add a `lazy` boolean attribute to `RESTObject`John L. Villalovos2022-07-201-2/+2
| | | | | | | | This can be used to tell if a `RESTObject` was created using `lazy=True`. Add a message to the `AttributeError` if attribute access fails for an instance created with `lazy=True`.
* refactor: avoid possible breaking change in iterator (#2107)John Villalovos2022-06-271-2/+5
| | | | | | | | Commit b6447211754e126f64e12fc735ad74fe557b7fb4 inadvertently introduced a possible breaking change as it added a new argument `iterator` and added it in between existing (potentially positional) arguments. This moves the `iterator` argument to the end of the argument list and requires it to be a keyword-only argument.
* feat(downloads): allow streaming downloads access to response iterator (#1956)Tom Catshoek2022-06-261-2/+6
| | | | | | | | | | | | | | | * 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
* refactor: remove no-op id argument in GetWithoutIdMixinNejc Habjan2022-06-251-3/+1
|
* feat(api): support head() method for get and list endpointsNejc Habjan2022-06-251-3/+31
|
* chore: enable pylint check: "no-else-return"John L. Villalovos2022-06-041-2/+1
| | | | Enable the pylint check "no-else-return" and fix the errors detected.
* chore: enable pylint checksJohn L. Villalovos2022-06-041-6/+0
| | | | | | | | Enable the pylint checks: * unnecessary-pass * unspecified-encoding Update code to resolve errors found
* chore: move `utils._validate_attrs` inside `types.RequiredOptional`John L. Villalovos2022-05-311-4/+2
| | | | | | Move the `validate_attrs` function to be inside the `RequiredOptional` class. It makes sense for it to be part of the class as it is working on data related to the class.
* feat: support mutually exclusive attributes and consolidate validation to ↵Walter Rowe2022-05-311-27/+7
| | | | | | | | | | | | | | | fix board lists (#2037) add exclusive tuple to RequiredOptional data class to support for mutually exclusive attributes consolidate _check_missing_create_attrs and _check_missing_update_attrs from mixins.py into _validate_attrs in utils.py change _create_attrs in board list manager classes from required=('label_ld',) to exclusive=('label_id','asignee_id','milestone_id') closes https://github.com/python-gitlab/python-gitlab/issues/1897
* chore: update type-hints return signature for GetWithoutIdMixin methodsJohn L. Villalovos2022-05-301-1/+1
| | | | | | | Commit f0152dc3cc9a42aa4dc3c0014b4c29381e9b39d6 removed situation where `get()` in a `GetWithoutIdMixin` based class could return `None` Update the type-hints to no longer return `Optional` AKA `None`
* chore(mixins): remove None check as http_get always returns valueNejc Habjan2022-05-291-2/+0
|
* feat(client): introduce `iterator=True` and deprecate `as_list=False` in ↵John L. Villalovos2022-05-291-4/+2
| | | | | | | | | | | `list()` `as_list=False` is confusing as it doesn't explain what is being returned. Replace it with `iterator=True` which more clearly explains to the user that an iterator/generator will be returned. This maintains backward compatibility with `as_list` but does issue a DeprecationWarning if `as_list` is set.
* refactor(mixins): extract custom type transforms into utilsNejc Habjan2022-05-291-44/+4
|
* feat(mixins): allow deleting resources without IDsNejc Habjan2022-02-101-1/+4
|
* style: use literals to declare data structuresNejc Habjan2022-01-231-1/+1
|
* chore: create return type-hints for `get_id()` & `encoded_id`John L. Villalovos2022-01-141-0/+1
| | | | | | Create return type-hints for `RESTObject.get_id()` and `RESTObject.encoded_id`. Previously was saying they return Any. Be more precise in saying they can return either: None, str, or int.
* feat(api): return result from `SaveMixin.save()`kernelport2022-01-131-4/+7
| | | | | | | | | Return the new object data when calling `SaveMixin.save()`. Also remove check for `None` value when calling `self.manager.update()` as that method only returns a dictionary. Closes: #1081
* chore: replace usage of utils._url_encode() with utils.EncodedId()jlvillal/encoded_idJohn L. Villalovos2022-01-131-4/+5
| | | | | | utils.EncodedId() has basically the same functionalityy of using utils._url_encode(). So remove utils._url_encode() as we don't need it.
* chore: add EncodedId string class to use to hold URL-encoded pathsJohn L. Villalovos2022-01-131-4/+2
| | | | | | | | | Add EncodedId string class. This class returns a URL-encoded string but ensures it will only URL-encode it once even if recursively called. Also added some functional tests of 'lazy' objects to make sure they work.
* fix: use url-encoded ID in all pathsJohn L. Villalovos2022-01-131-19/+18
| | | | | | | | | | | | Make sure all usage of the ID in the URL path is encoded. Normally it isn't an issue as most IDs are integers or strings which don't contain a slash ('/'). But when the ID is a string with a slash character it will break things. Add a test case that shows this fixes wikis issue with subpages which use the slash character. Closes: #1079
* fix: remove custom URL encodingJohn L. Villalovos2022-01-081-3/+3
| | | | | | | | | | 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
* Merge pull request #1709 from python-gitlab/docs/sphinx-annotationsNejc Habjan2021-12-011-33/+33
|\ | | | | docs: only use type annotations for documentation
| * docs: use annotations for return typesdocs/sphinx-annotationsNejc Habjan2021-12-011-12/+12
| |
| * docs: only use type annotations for documentationNejc Habjan2021-11-281-21/+21
| |
* | Merge pull request #1702 from python-gitlab/jlvillal/attribute_helpNejc Habjan2021-12-011-1/+1
|\ \ | | | | | | chore: attempt to be more informative for missing attributes
| * | chore: attempt to be more informative for missing attributesjlvillal/attribute_helpJohn L. Villalovos2021-11-301-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A commonly reported issue from users on Gitter is that they get an AttributeError for an attribute that should be present. This is often caused due to the fact that they used the `list()` method to retrieve the object and objects retrieved this way often only have a subset of the full data. Add more details in the AttributeError message that explains the situation to users. This will hopefully allow them to resolve the issue. Update the FAQ in the docs to add a section discussing the issue. Closes #1138
* | chore: use constants from gitlab.const moduleJohn L. Villalovos2021-11-301-1/+1
|/ | | | | Have code use constants from the gitlab.const module instead of from the top-level gitlab module.
* refactor: use f-strings for string formattingNejc Habjan2021-11-051-23/+23
|
* feat(api): add project label promotionRaimund Hook2021-10-181-0/+47
| | | | | | Adds a mixin that allows the /promote endpoint to be called. Signed-off-by: Raimund Hook <raimund.hook@exfo.com>
* docs: fix a few typosTim Gates2021-09-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | There are small typos in: - docs/gl_objects/deploy_tokens.rst - gitlab/base.py - gitlab/mixins.py - gitlab/v4/objects/features.py - gitlab/v4/objects/groups.py - gitlab/v4/objects/packages.py - gitlab/v4/objects/projects.py - gitlab/v4/objects/sidekiq.py - gitlab/v4/objects/todos.py Fixes: - Should read `treatment` rather than `reatment`. - Should read `transferred` rather than `transfered`. - Should read `registered` rather than `registred`. - Should read `occurred` rather than `occured`. - Should read `overridden` rather than `overriden`. - Should read `marked` rather than `maked`. - Should read `instantiate` rather than `instanciate`. - Should read `function` rather than `fonction`.
* refactor(objects): remove deprecated members.all() methodNejc Habjan2021-09-081-48/+0
| | | | | BREAKING CHANGE: remove deprecated members.all() method in favor of members_all.list()
* fix(mixins): improve deprecation warningMax Wittig2021-08-131-1/+1
| | | Also note what should be changed
* fix: ensure kwargs are passed appropriately for ObjectDeleteMixinBen Brown2021-06-011-1/+1
|
* chore: fix import ordering using isortJohn L. Villalovos2021-05-251-3/+2
| | | | | | Fix the import ordering using isort. https://pycqa.github.io/isort/
* feat: add feature to get inherited member for project/groupOleksii Shkurupii2021-05-071-1/+48
|
* Merge pull request #1412 from JohnVillalovos/jlvillal/optional_get_attrsNejc Habjan2021-04-261-0/+2
|\ | | | | chore: make Get.*Mixin._optional_get_attrs always present
| * chore: make Get.*Mixin._optional_get_attrs always presentJohn L. Villalovos2021-04-241-0/+3
| | | | | | | | | | | | | | | | 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.
* | chore: make ListMixin._list_filters always presentJohn L. Villalovos2021-04-241-0/+2
|/ | | | | | | | 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.
* Merge pull request #1397 from JohnVillalovos/jlvillal/flake8Max Wittig2021-04-231-1/+0
|\ | | | | Fix all issues reported by running: tox -e pep8 and enable pep8 as a linter check
| * chore: fix F401 errors reported by flake8John L. Villalovos2021-04-181-1/+0
| | | | | | | | | | | | F401: Module imported but unused https://www.flake8rules.com/rules/F401.html
* | fix: correct some type-hints in gitlab/mixins.pyJohn L. Villalovos2021-04-181-24/+26
|/ | | | | | | | | | | | | Commit baea7215bbbe07c06b2ca0f97a1d3d482668d887 introduced type-hints for gitlab/mixins.py. After starting to add type-hints to gitlab/v4/objects/users.py discovered a few errors. Main error was using '=' instead of ':'. For example: _parent = Optional[...] should be _parent: Optional[...] Resolved those issues.
* Merge pull request #1375 from JohnVillalovos/jlvillal/update_uses_postNejc Habjan2021-04-171-1/+2
|\ | | | | chore: remove usage of getattr()
| * chore: remove usage of getattr()John L. Villalovos2021-03-151-1/+2
| | | | | | | | | | | | | | | | | | Remove usage of getattr(self, "_update_uses_post", False) Instead add it to class and set default value to False. Add a tests that shows it is set to True for the ProjectMergeRequestApprovalManager and ProjectApprovalManager classes.
* | chore: have _create_attrs & _update_attrs be a namedtupleJohn L. Villalovos2021-04-171-3/+3
|/ | | | | | 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-25/+7
| | | | | | | 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.
* chore: make _types always present in RESTManagerJohn L. Villalovos2021-03-071-11/+8
| | | | | | | | | | 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.