fix some issues and update docs

pull/397/head
halcy 2025-02-14 02:10:42 +02:00
rodzic 120f092ca2
commit 5bbf2bb3bf
3 zmienionych plików z 15 dodań i 11 usunięć

Wyświetl plik

@ -19,6 +19,8 @@ v2.0.0 (IN PROGRESS)
* Fix version parsing for GoToSocial (Thanks gmemstr)
* Updated docs to reflect the fact that startign with 4.4.0, the password grant type is no longer supported.
* Added support for following tags (`followed_tags`, `tag_follow`, `tag_unfollow`, `tag`)
* Fix library not working with -O2 (Thanks mirabilos for the report)
* Version check mode now defaults to "none", since it keeps causing more problems than it solves.
v1.8.1
------

Wyświetl plik

@ -93,7 +93,7 @@ class Mastodon(Internals):
def __init__(self, client_id: Optional[Union[str, PurePath]] = None, client_secret: Optional[str] = None,
access_token: Optional[Union[str, PurePath]] = None, api_base_url: Optional[str] = None, debug_requests: bool = False,
ratelimit_method: str = "wait", ratelimit_pacefactor: float = 1.1, request_timeout: float = _DEFAULT_TIMEOUT,
mastodon_version: Optional[str] =None, version_check_mode: str = "created", session: Optional[requests.Session] = None,
mastodon_version: Optional[str] = None, version_check_mode: str = "none", session: Optional[requests.Session] = None,
feature_set: str = "mainline", user_agent: str = _DEFAULT_USER_AGENT, lang: Optional[str] = None):
"""
Create a new API wrapper instance based on the given `client_secret` and `client_id` on the
@ -126,12 +126,6 @@ class Mastodon(Internals):
Version is specified. If no version is specified, Mastodon.py will set `mastodon_version` to the
detected version.
The version check mode can be set to "created" (the default behaviour), "changed" or "none". If set to
"created", Mastodon.py will throw an error if the version of Mastodon it is connected to is too old
to have an endpoint. If it is set to "changed", it will throw an error if the endpoint's behaviour has
changed after the version of Mastodon that is connected has been released. If it is set to "none",
version checking is disabled.
`feature_set` can be used to enable behaviour specific to non-mainline Mastodon API implementations.
Details are documented in the functions that provide such functionality. Currently supported feature
sets are `mainline`, `fedibird` and `pleroma`.
@ -145,6 +139,13 @@ class Mastodon(Internals):
or for a language that has none, 639-3 (three letter) language codes. This affects some error messages (those related to validation) and
trends. You can change the language using :ref:`set_language()`.
The version check mode can be set to "none" (now the default behaviour), "changed" or "created". If set to
"created", Mastodon.py will throw an error if the version of Mastodon it is connected to is too old
to have an endpoint. If it is set to "changed", it will throw an error if the endpoint's behaviour has
changed after the version of Mastodon that is connected has been released. If it is set to "none",
version checking is disabled. When encountering problems, I would recommend setting this to "created"
and/or setting `debug_requests` to True to get a better idea of what is going on.
If no other `User-Agent` is specified, "mastodonpy" will be used.
"""
self.api_base_url = api_base_url

Wyświetl plik

@ -35,13 +35,14 @@ def api_version(created_ver, last_changed_ver, return_value_ver):
version = max_version(last_changed_ver, return_value_ver)
major, minor, patch = parse_version_string(version)
if major > self.mastodon_major:
raise MastodonVersionError(f"Version check failed (Need version {version})")
raise MastodonVersionError(f"Version check failed (Need Mastodon instance version {version} to call this endpoint)")
elif major == self.mastodon_major and minor > self.mastodon_minor:
raise MastodonVersionError(f"Version check failed (Need version {version})")
raise MastodonVersionError(f"Version check failed (Need Mastodon instance version {version}) to call this endpoint)")
elif major == self.mastodon_major and minor == self.mastodon_minor and patch > self.mastodon_patch:
raise MastodonVersionError(f"Version check failed (Need version {version}, patch is {self.mastodon_patch})")
raise MastodonVersionError(f"Version check failed (Need Mastodon instance version {version} to call this endpoint). Patch is {self.mastodon_patch}.")
return function(self, *args, **kwargs)
function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*"
if function.__doc__:
function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*"
return decorate(function, wrapper)
return api_min_version_decorator