kopia lustrzana https://github.com/halcy/Mastodon.py
refactor some stuff to rename types, since that shadows a functools module, and update docs
rodzic
3e78acb406
commit
8f563d5e60
|
@ -16,6 +16,7 @@ v2.0.0 (IN PROGRESS)
|
||||||
* Added CITATION.cff (Thanks @hauschke for the suggestion)
|
* Added CITATION.cff (Thanks @hauschke for the suggestion)
|
||||||
* Fixed a potential issue with modification to locals (Thanks Konano)
|
* Fixed a potential issue with modification to locals (Thanks Konano)
|
||||||
* Added support for 4.3.0 `accounts` endpoint (Thanks AlexKalopsia)
|
* Added support for 4.3.0 `accounts` endpoint (Thanks AlexKalopsia)
|
||||||
|
* Fix version parsing for GoToSocial (Thanks gmemstr)
|
||||||
|
|
||||||
v1.8.1
|
v1.8.1
|
||||||
------
|
------
|
||||||
|
|
|
@ -19,20 +19,29 @@ Register your app! This only needs to be done once (per server, or when distribu
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Then, log in. This can be done every time your application starts (e.g. when writing a simple bot), or you can use the persisted information:
|
Then, log in. This can be done every time your application starts, or you can use the persisted information:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
|
|
||||||
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
|
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
|
||||||
|
print(mastodon.auth_request_url())
|
||||||
|
|
||||||
|
# open the URL in the browser and paste the code you get
|
||||||
mastodon.log_in(
|
mastodon.log_in(
|
||||||
'my_login_email@example.com',
|
code=input("Enter the OAuth authorization code: "),
|
||||||
'incrediblygoodpassword',
|
to_file="pytooter_usercred.secret"
|
||||||
to_file = 'pytooter_usercred.secret'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Note that this won't work when using 2FA - you'll have to use OAuth, in that case. To post, create an actual API instance:
|
|
||||||
|
Note that previous versions of Mastodon allowed logging in with username and
|
||||||
|
password - unfortunately, due to security concerns, Mastodon has started
|
||||||
|
requiring OAuth starting with version 4.4.0. If you're building a bot, you
|
||||||
|
may with to instead just generate a token in the UI (On Mastodon:
|
||||||
|
your-server.com/settings/applications) and use it directly
|
||||||
|
|
||||||
|
To post, create an actual API instance:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ from mastodon.compat import urlparse
|
||||||
from mastodon.utility import parse_version_string, max_version, api_version
|
from mastodon.utility import parse_version_string, max_version, api_version
|
||||||
from mastodon.utility import Mastodon as MastoUtility
|
from mastodon.utility import Mastodon as MastoUtility
|
||||||
|
|
||||||
from mastodon.types import *
|
from mastodon.return_types import *
|
||||||
from mastodon.errors import *
|
from mastodon.errors import *
|
||||||
|
|
||||||
from mastodon.versions import _DICT_VERSION_APPLICATION, _DICT_VERSION_MENTION, _DICT_VERSION_MEDIA, _DICT_VERSION_ACCOUNT, _DICT_VERSION_POLL, \
|
from mastodon.versions import _DICT_VERSION_APPLICATION, _DICT_VERSION_MENTION, _DICT_VERSION_MEDIA, _DICT_VERSION_ACCOUNT, _DICT_VERSION_POLL, \
|
||||||
|
|
|
@ -10,7 +10,7 @@ from mastodon.utility import api_version
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
|
|
||||||
from typing import Union, Optional, Tuple, List
|
from typing import Union, Optional, Tuple, List
|
||||||
from mastodon.types import AccountCreationError, Account, IdType, Status, PaginatableList, NonPaginatableList, UserList, Relationship, FamiliarFollowers, Tag, IdType, PathOrFile, AttribAccessDict, try_cast
|
from mastodon.return_types import AccountCreationError, Account, IdType, Status, PaginatableList, NonPaginatableList, UserList, Relationship, FamiliarFollowers, Tag, IdType, PathOrFile, AttribAccessDict, try_cast
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from typing import Optional, List, Union
|
from typing import Optional, List, Union
|
||||||
from mastodon.types import IdType, PrimitiveIdType, Account, AdminAccount, AdminReport, PaginatableList, NonPaginatableList, Status, Tag,\
|
from mastodon.return_types import IdType, PrimitiveIdType, Account, AdminAccount, AdminReport, PaginatableList, NonPaginatableList, Status, Tag,\
|
||||||
PreviewCard, AdminDomainBlock, AdminMeasure, AdminDimension, AdminRetention
|
PreviewCard, AdminDomainBlock, AdminMeasure, AdminDimension, AdminRetention
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from mastodon.utility import parse_version_string, api_version
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.utility import Mastodon as Utility
|
from mastodon.utility import Mastodon as Utility
|
||||||
from typing import List, Optional, Union, Tuple
|
from typing import List, Optional, Union, Tuple
|
||||||
from mastodon.types import Application
|
from mastodon.return_types import Application
|
||||||
from mastodon.compat import PurePath
|
from mastodon.compat import PurePath
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
@ -312,9 +312,9 @@ class Mastodon(Internals):
|
||||||
generating the auth request URL. If passing `code`you should not pass `username` or `password`.
|
generating the auth request URL. If passing `code`you should not pass `username` or `password`.
|
||||||
|
|
||||||
When using the password flow, the username is the email address used to log in into Mastodon.
|
When using the password flow, the username is the email address used to log in into Mastodon.
|
||||||
Note that Mastodon has expressed that they intend to remove this login method - if you are currently
|
Note that Mastodon has removed this flow starting with 4.4.0, so it is unfortunately not
|
||||||
using it, please consider migrating to OAuth2 (or, for single-user bots, generating a token manually
|
possible to log in in this way anymore. Please use either the code flow, or generate
|
||||||
via the web interface).
|
a token from the web UI.
|
||||||
|
|
||||||
Can persist access token to file `to_file`, to be used in the constructor.
|
Can persist access token to file `to_file`, to be used in the constructor.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ except:
|
||||||
|
|
||||||
IMPL_HAS_ECE = True
|
IMPL_HAS_ECE = True
|
||||||
try:
|
try:
|
||||||
import http_ece
|
import http_ece # type: ignore
|
||||||
except:
|
except:
|
||||||
IMPL_HAS_ECE = False
|
IMPL_HAS_ECE = False
|
||||||
http_ece = None
|
http_ece = None
|
||||||
|
@ -30,7 +30,7 @@ except:
|
||||||
try:
|
try:
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse # type: ignore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
|
|
|
@ -5,7 +5,7 @@ from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
from mastodon.types import IdType, PaginatableList, Conversation
|
from mastodon.return_types import IdType, PaginatableList, Conversation
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
###
|
###
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_ACCOUNT
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Account, NonPaginatableList
|
from mastodon.return_types import Account, NonPaginatableList
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
###
|
###
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_STATUS
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Status, IdType, PaginatableList
|
from mastodon.return_types import Status, IdType, PaginatableList
|
||||||
|
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_FEATURED_TAG, _DICT_VERSION_HASHTAG
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Tag, NonPaginatableList, PaginatableList, FeaturedTag, IdType
|
from mastodon.return_types import Tag, NonPaginatableList, PaginatableList, FeaturedTag, IdType
|
||||||
from mastodon.errors import MastodonIllegalArgumentError
|
from mastodon.errors import MastodonIllegalArgumentError
|
||||||
|
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
|
@ -6,7 +6,7 @@ from mastodon.utility import api_version
|
||||||
from mastodon.compat import urlparse
|
from mastodon.compat import urlparse
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Instance, InstanceV2, NonPaginatableList, Activity, Nodeinfo, AttribAccessDict, Rule, Announcement, CustomEmoji, Account, IdType
|
from mastodon.return_types import Instance, InstanceV2, NonPaginatableList, Activity, Nodeinfo, AttribAccessDict, Rule, Announcement, CustomEmoji, Account, IdType
|
||||||
|
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,7 @@ from mastodon.errors import MastodonNetworkError, MastodonIllegalArgumentError,
|
||||||
MastodonGatewayTimeoutError, MastodonServerError, MastodonAPIError, MastodonMalformedEventError
|
MastodonGatewayTimeoutError, MastodonServerError, MastodonAPIError, MastodonMalformedEventError
|
||||||
from mastodon.compat import urlparse, magic, PurePath, Path
|
from mastodon.compat import urlparse, magic, PurePath, Path
|
||||||
from mastodon.defaults import _DEFAULT_STREAM_TIMEOUT, _DEFAULT_STREAM_RECONNECT_WAIT_SEC
|
from mastodon.defaults import _DEFAULT_STREAM_TIMEOUT, _DEFAULT_STREAM_RECONNECT_WAIT_SEC
|
||||||
from mastodon.types import AttribAccessDict, PaginatableList, try_cast_recurse
|
from mastodon.return_types import *
|
||||||
from mastodon.types import *
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Internal helpers, dragons probably
|
# Internal helpers, dragons probably
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_LIST, _DICT_VERSION_ACCOUNT
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import NonPaginatableList, UserList, IdType, PaginatableList, Account
|
from mastodon.return_types import NonPaginatableList, UserList, IdType, PaginatableList, Account
|
||||||
|
|
||||||
from typing import List, Union, Optional
|
from typing import List, Union, Optional
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from mastodon.errors import MastodonVersionError, MastodonAPIError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import MediaAttachment, PathOrFile, IdType
|
from mastodon.return_types import MediaAttachment, PathOrFile, IdType
|
||||||
|
|
||||||
from typing import Optional, Union, Tuple, List, Dict, Any
|
from typing import Optional, Union, Tuple, List, Dict, Any
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from mastodon.errors import MastodonIllegalArgumentError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Notification, IdType, PaginatableList, Account
|
from mastodon.return_types import Notification, IdType, PaginatableList, Account
|
||||||
from typing import Union, Optional, List
|
from typing import Union, Optional, List
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_POLL
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Poll, IdType
|
from mastodon.return_types import Poll, IdType
|
||||||
from typing import Union, List
|
from typing import Union, List
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from mastodon.errors import MastodonIllegalArgumentError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Preferences, Marker, Status, IdType
|
from mastodon.return_types import Preferences, Marker, Status, IdType
|
||||||
from typing import Union, List, Dict
|
from typing import Union, List, Dict
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from mastodon.compat import IMPL_HAS_CRYPTO, ec, serialization, default_backend
|
||||||
from mastodon.compat import IMPL_HAS_ECE, http_ece
|
from mastodon.compat import IMPL_HAS_ECE, http_ece
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import WebpushCryptoParamsPubkey, WebpushCryptoParamsPrivkey, WebPushSubscription, PushNotification, try_cast_recurse
|
from mastodon.return_types import WebpushCryptoParamsPubkey, WebpushCryptoParamsPrivkey, WebPushSubscription, PushNotification, try_cast_recurse
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_ACCOUNT, _DICT_VERSION_RELATIONSHIP
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Account, Relationship, PaginatableList, IdType
|
from mastodon.return_types import Account, Relationship, PaginatableList, IdType
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from mastodon.errors import MastodonVersionError, MastodonIllegalArgumentError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import NonPaginatableList, Report, Account, IdType, Status, Rule
|
from mastodon.return_types import NonPaginatableList, Report, Account, IdType, Status, Rule
|
||||||
from typing import Union, Optional, List
|
from typing import Union, Optional, List
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from mastodon.errors import MastodonVersionError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Search, SearchV2, Account, IdType
|
from mastodon.return_types import Search, SearchV2, Account, IdType
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -9,7 +9,7 @@ from mastodon.errors import MastodonIllegalArgumentError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Status, IdType, ScheduledStatus, PreviewCard, Context, NonPaginatableList, Account,\
|
from mastodon.return_types import Status, IdType, ScheduledStatus, PreviewCard, Context, NonPaginatableList, Account,\
|
||||||
MediaAttachment, Poll, StatusSource, StatusEdit, PaginatableList
|
MediaAttachment, Poll, StatusSource, StatusEdit, PaginatableList
|
||||||
|
|
||||||
from typing import Union, Optional, List
|
from typing import Union, Optional, List
|
||||||
|
|
|
@ -11,7 +11,7 @@ except:
|
||||||
|
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout
|
from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout
|
||||||
from mastodon.types import AttribAccessDict, Status, Notification, IdType, Conversation, Announcement, StreamReaction, try_cast_recurse
|
from mastodon.return_types import AttribAccessDict, Status, Notification, IdType, Conversation, Announcement, StreamReaction, try_cast_recurse
|
||||||
|
|
||||||
from requests.exceptions import ChunkedEncodingError, ReadTimeout, ConnectionError
|
from requests.exceptions import ChunkedEncodingError, ReadTimeout, ConnectionError
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_ACCOUNT
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import NonPaginatableList, Account, IdType, Suggestion
|
from mastodon.return_types import NonPaginatableList, Account, IdType, Suggestion
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from mastodon.errors import MastodonIllegalArgumentError, MastodonNotFoundError
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Status, IdType, PaginatableList, UserList
|
from mastodon.return_types import Status, IdType, PaginatableList, UserList
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from mastodon.versions import _DICT_VERSION_HASHTAG, _DICT_VERSION_STATUS, _DICT
|
||||||
from mastodon.utility import api_version
|
from mastodon.utility import api_version
|
||||||
|
|
||||||
from mastodon.internals import Mastodon as Internals
|
from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.types import Tag, Status, PreviewCard, NonPaginatableList
|
from mastodon.return_types import Tag, Status, PreviewCard, NonPaginatableList
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
5286
mastodon/types.py
5286
mastodon/types.py
Plik diff jest za duży
Load Diff
|
@ -142,7 +142,7 @@ if sys.version_info < (3, 9):
|
||||||
def resolve_type(t):
|
def resolve_type(t):
|
||||||
# I'm sorry about this, but I cannot think of another way to make this work properly in versions below 3.9 that
|
# I'm sorry about this, but I cannot think of another way to make this work properly in versions below 3.9 that
|
||||||
# cannot resolve forward references in a sane way
|
# cannot resolve forward references in a sane way
|
||||||
from mastodon.types import Account, AccountField, Role, CredentialAccountSource, Status, StatusEdit, FilterResult,\
|
from mastodon.return_types import Account, AccountField, Role, CredentialAccountSource, Status, StatusEdit, FilterResult,\
|
||||||
StatusMention, ScheduledStatus, ScheduledStatusParams, Poll, PollOption, Conversation, Tag, TagHistory, CustomEmoji,\
|
StatusMention, ScheduledStatus, ScheduledStatusParams, Poll, PollOption, Conversation, Tag, TagHistory, CustomEmoji,\
|
||||||
Application, Relationship, Filter, FilterV2, Notification, Context, UserList, MediaAttachment, MediaAttachmentMetadataContainer,\
|
Application, Relationship, Filter, FilterV2, Notification, Context, UserList, MediaAttachment, MediaAttachmentMetadataContainer,\
|
||||||
MediaAttachmentImageMetadata, MediaAttachmentVideoMetadata, MediaAttachmentAudioMetadata, MediaAttachmentFocusPoint, MediaAttachmentColors, \
|
MediaAttachmentImageMetadata, MediaAttachmentVideoMetadata, MediaAttachmentAudioMetadata, MediaAttachmentFocusPoint, MediaAttachmentColors, \
|
||||||
|
@ -292,7 +292,7 @@ def try_cast_recurse(t, value, union_specializer=None):
|
||||||
elif orig_type is Union:
|
elif orig_type is Union:
|
||||||
real_type = None
|
real_type = None
|
||||||
if union_specializer is not None:
|
if union_specializer is not None:
|
||||||
from mastodon.types import MediaAttachmentImageMetadata, MediaAttachmentVideoMetadata, MediaAttachmentAudioMetadata
|
from mastodon.return_types import MediaAttachmentImageMetadata, MediaAttachmentVideoMetadata, MediaAttachmentAudioMetadata
|
||||||
real_type = {
|
real_type = {
|
||||||
"image": MediaAttachmentImageMetadata,
|
"image": MediaAttachmentImageMetadata,
|
||||||
"video": MediaAttachmentVideoMetadata,
|
"video": MediaAttachmentVideoMetadata,
|
||||||
|
@ -466,7 +466,7 @@ class AttribAccessDict(OrderedStrDict):
|
||||||
# Note for developers: This means type MUST be set before meta. fortunately, we can enforce this via
|
# Note for developers: This means type MUST be set before meta. fortunately, we can enforce this via
|
||||||
# the type hints (assuming that the order of annotations is not changed, which python does not guarantee,
|
# the type hints (assuming that the order of annotations is not changed, which python does not guarantee,
|
||||||
# if it ever does: we'll have to add another hack to the constructor)
|
# if it ever does: we'll have to add another hack to the constructor)
|
||||||
from mastodon.types import MediaAttachment
|
from return_types import MediaAttachment
|
||||||
if type(self) == MediaAttachment and key == "type":
|
if type(self) == MediaAttachment and key == "type":
|
||||||
self.__union_specializer = val
|
self.__union_specializer = val
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from mastodon.internals import Mastodon as Internals
|
||||||
from mastodon.versions import parse_version_string, max_version, api_version
|
from mastodon.versions import parse_version_string, max_version, api_version
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from mastodon.types import PaginatableList, PaginationInfo
|
from mastodon.return_types import PaginatableList, PaginationInfo
|
||||||
|
|
||||||
# Class level:
|
# Class level:
|
||||||
class Mastodon(Internals):
|
class Mastodon(Internals):
|
||||||
|
|
Ładowanie…
Reference in New Issue