| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
Update code so that the `warn_return_any` check passes.
|
|\
| |
| | |
feat: add `asdict()` and `to_json()` methods to Gitlab Objects
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add an `asdict()` method that returns a dictionary representation copy
of the Gitlab Object. This is a copy and changes made to it will have
no impact on the Gitlab Object.
The `asdict()` method name was chosen as both the `dataclasses` and
`attrs` libraries have an `asdict()` function which has the similar
purpose of creating a dictionary represenation of an object.
Also add a `to_json()` method that returns a JSON string
representation of the object.
Closes: #1116
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously the `attributes` method would show the original values in a
Gitlab Object even if they had been updated. Correct this so that the
updated value will be returned.
Also use copy.deepcopy() to ensure that modifying the dictionary returned can
not also modify the object.
|
|/
|
|
|
|
|
|
| |
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`.
|
|\
| |
| | |
chore: simplify multi-nested try blocks
|
| |
| |
| |
| |
| | |
Instead of have a multi-nested series of try blocks. Convert it to a
more readable series of `if` statements.
|
|/
|
|
|
|
|
| |
Ensure the path elements that are passed to the server are escaped.
For example a "/" will be changed to "%2F"
Closes: #2116
|
| |
|
|
|
|
|
| |
We previously converted all string formatting to use f-strings. Enable
pylint check to enforce this.
|
|
|
|
|
|
| |
By having `RequiredOptional` in the `gitlab.base` module it makes it
difficult with circular imports. Move it to the `gitlab.types`
module which has no dependencies on any other gitlab module.
|
| |
|
|
|
|
|
|
|
| |
There are occasions where a GitLab `list()` call does not return the
`x-per-page` header. For example the listing of custom attributes.
Update the type-hints to reflect that.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
utils.EncodedId() has basically the same functionalityy of using
utils._url_encode(). So remove utils._url_encode() as we don't need
it.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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' --------------------------^
|
|
|
|
|
| |
This is useful in debugging and testing. As can easily print out the
values from an instance in a more human-readable form.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\
| |
| | |
docs: only use type annotations for documentation
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Fix the import ordering using isort.
https://pycqa.github.io/isort/
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
fix(types): prevent __dir__ in RestObject from producing duplicates
|
| | |
|
|/
|
|
|
|
| |
Convert _create_attrs and _update_attrs to use a NamedTuple
(RequiredOptional) to help with code readability. Update all code to
use the NamedTuple.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Add some additional type hints to gitlab/base.py
|
|
|
|
|
|
|
|
|
|
| |
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, ...]
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
chore: add type-hints to gitlab/client.py
|
| |
| |
| |
| | |
Adding some initial type-hints to gitlab/client.py
|
|/
|
|
| |
Determined the base class for obj_cls and adding type-hints for it.
|
| |
|