summaryrefslogtreecommitdiff
path: root/gitlab/base.py
Commit message (Collapse)AuthorAgeFilesLines
* chore: create return type-hints for `get_id()` & `encoded_id`John L. Villalovos2022-01-141-3/+3
| | | | | | 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.
* 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: use url-encoded ID in all pathsJohn L. Villalovos2022-01-131-0/+9
| | | | | | | | | | | | 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: broken URL for FAQ about attribute-error-listJohn L. Villalovos2022-01-091-1/+1
| | | | | | | | | | | | | | The URL was missing a 'v' before the version number and thus the page did not exist. Previously the URL for python-gitlab 3.0.0 was: https://python-gitlab.readthedocs.io/en/3.0.0/faq.html#attribute-error-list Which does not exist. Change it to: https://python-gitlab.readthedocs.io/en/v3.0.0/faq.html#attribute-error-list add the 'v' --------------------------^
* chore: add `pprint()` and `pformat()` methods to RESTObjectJohn L. Villalovos2022-01-081-0/+9
| | | | | This is useful in debugging and testing. As can easily print out the values from an instance in a more human-readable form.
* fix: handle situation where GitLab does not return valuesjlvillal/paginationJohn L. Villalovos2021-12-301-2/+2
| | | | | | | | | | | | | | | | If a query returns more than 10,000 records than the following values are NOT returned: x.total_pages x.total Modify the code to allow no value to be set for these values. If there is not a value returned the functions will now return None. Update unit test so no longer `xfail` https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers Closes #1686
* Merge pull request #1709 from python-gitlab/docs/sphinx-annotationsNejc Habjan2021-12-011-2/+1
|\ | | | | docs: only use type annotations for documentation
| * docs: only use type annotations for documentationNejc Habjan2021-11-281-2/+1
| |
* | chore: attempt to be more informative for missing attributesjlvillal/attribute_helpJohn L. Villalovos2021-11-301-4/+34
|/ | | | | | | | | | | | | | | | 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: fix issue with adding type-hints to 'manager' attributeJohn L. Villalovos2021-11-211-0/+4
| | | | | | | | | | | | When attempting to add type-hints to the the 'manager' attribute into a RESTObject derived class it would break things. This was because our auto-manager creation code would automatically add the specified annotated manager to the 'manager' attribute. This breaks things. Now check in our auto-manager creation if our attribute is called 'manager'. If so we ignore it.
* refactor: use new-style formatting for named placeholdersNejc Habjan2021-11-081-1/+1
|
* refactor: use f-strings for string formattingNejc Habjan2021-11-051-7/+3
|
* docs: fix a few typosTim Gates2021-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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`.
* chore: convert to using type-annotations for managersJohn L. Villalovos2021-09-081-5/+13
| | | | | | | | | | | | | Convert our manager usage to be done via type annotations. Now to define a manager to be used in a RESTObject subclass can simply do: class ExampleClass(CRUDMixin, RESTObject): my_manager: MyManager Any type-annotation that annotates it to be of type *Manager (with the exception of RESTManager) will cause the manager to be created on the object.
* chore: improve type-hinting for managersJohn L. Villalovos2021-09-071-2/+3
| | | | | | | | | | | | | | | 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
* fix: catch invalid type used to initialize RESTObjectJohn L. Villalovos2021-06-101-0/+7
| | | | | | | | Sometimes we have errors where we don't get a dictionary passed to RESTObject.__init__() method. This breaks things but in confusing ways. Check in the __init__() method and raise an exception if it occurs.
* chore: fix import ordering using isortJohn L. Villalovos2021-05-251-1/+2
| | | | | | Fix the import ordering using isort. https://pycqa.github.io/isort/
* chore: mypy: Disallow untyped definitionsJohn L. Villalovos2021-04-271-6/+6
| | | | | | | | | Be more strict and don't allow untyped definitions on the files we check. Also this adds type-hints for two of the decorators so that now functions/methods decorated by them will have their types be revealed correctly.
* chore: make RESTObject._short_print_attrs always presentJohn L. Villalovos2021-04-241-0/+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.
* Merge pull request #1383 from spyoungtech/dirfixNejc Habjan2021-04-211-1/+1
|\ | | | | fix(types): prevent __dir__ in RestObject from producing duplicates
| * fix(types): prevent __dir__ from producing duplicatesSpencer Young2021-03-231-1/+1
| |
* | chore: have _create_attrs & _update_attrs be a namedtupleJohn L. Villalovos2021-04-171-3/+9
|/ | | | | | 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-1/+3
| | | | | | | 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-2/+2
| | | | | | | | | | | | 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-0/+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.
* chore: add type hints to gitlab/base.py:RESTManagerJohn L. Villalovos2021-03-011-0/+5
| | | | Add some additional type hints to gitlab/base.py
* chore: disallow incomplete type defsJohn L. Villalovos2021-02-281-4/+8
| | | | | | | | | | Don't allow a partially annotated function definition. Either none of the function is annotated or all of it must be. Update code to ensure no-more partially annotated functions. Update gitlab/cli.py with better type-hints. Changed Tuple[Any, ...] to Tuple[str, ...]
* chore: add additional type-hints for gitlab/base.pyJohn L. Villalovos2021-02-271-1/+7
| | | | | | | Add type-hints for the variables which are set via self.__dict__ mypy doesn't see them when they are assigned via self.__dict__. So declare them in the class definition.
* Merge pull request #1339 from JohnVillalovos/jlvillal/mypy_client_pyMax Wittig2021-02-271-2/+2
|\ | | | | chore: add type-hints to gitlab/client.py
| * chore: add type-hints to gitlab/client.pyJohn L. Villalovos2021-02-261-2/+2
| | | | | | | | Adding some initial type-hints to gitlab/client.py
* | chore: improve type-hints for gitlab/base.pyJohn L. Villalovos2021-02-261-3/+5
|/ | | | Determined the base class for obj_cls and adding type-hints for it.
* chore: add type hints to gitlab/base.pyJohn L. Villalovos2021-02-221-29/+34
|
* refactor(api): explicitly export classes for star importsrefactor/split-objectsNejc Habjan2021-02-071-0/+7
|
* fix(base): really refresh objectfix/delete-attrMax Wittig2020-10-121-1/+1
| | | | | | This fixes and error, where deleted attributes would not show up Fixes #1155
* feat(types): add __dir__ to RESTObject to expose attributesSpencer Young2020-04-131-0/+3
|
* docs: fix comment of prev_page()Donghui Wang2020-03-211-1/+1
| | | | Co-Authored-By: Nejc Habjan <hab.nejc@gmail.com>
* docs: fix comment of prev_page()donhui2020-03-201-2/+2
|
* refactor: remove unused code, simplify string formatgodaji2019-10-061-1/+1
|
* fix: improve pickle supportbourgesl2019-07-211-1/+1
|
* refactor: format everything blackrefactor/blackMax Wittig2019-05-161-31/+39
|
* fix: use python2 compatible syntax for superfix/python-testsMax Wittig2019-02-221-2/+7
|
* Implement __eq__ and __hash__ methodsJonathan Piron2019-02-201-1/+11
| | | | To ease lists and sets manipulations.
* Drop API v3 supportGauvain Pocentek2018-05-191-526/+0
| | | | Drop the code, the tests, and update the documentation.
* submanagers: allow having undefined parametersGauvain Pocentek2017-12-161-1/+1
| | | | | | | This might happen in CLI context, where recursion to discover parent attributes is not required (URL gets hardcoded) Fix should fix the CLI CI.
* Module's base objects serialization (#359)Lyudmil Nenov2017-11-031-0/+22
| | | | | | | | Make gitlab objects serializable With current implementation of API v3 and v4 support, some instances have properties of type module and are not serializable. Handle these properties manually with setstate and getstate methods.
* Pagination generators: expose more informationGauvain Pocentek2017-11-011-0/+36
| | | | | | | Expose the X-* pagination attributes returned by the Gitlab server when requesting lists. Closes #304
* Remove support for "constructor types" in v4Gauvain Pocentek2017-10-211-4/+0
| | | | | | In v3 we create objects from json dicts when it makes sense. Support for this feature has not been kept in v4, and we didn't get requests for it so let's drop the _constructor_types definitions.
* Fix the labels attrs on MR and issuesGauvain Pocentek2017-09-191-1/+18
| | | | Fixes #306
* adds project upload feature (#239)James Johnson2017-09-121-1/+1
|
* [v4] CLI support is backGauvain Pocentek2017-08-171-0/+7
|