Skip to content

Sourcery refactored backup branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intobackupfrom
sourcery/backup
Open

Sourcery refactored backup branch#1
sourcery-ai[bot] wants to merge 1 commit intobackupfrom
sourcery/backup

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Mar 18, 2022

Branch backup refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the backup branch, then run:

git fetch origin sourcery/backup
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from NoorXd786 March 18, 2022 04:25
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -169 to +174
for root, _dirs, _files in os.walk(LIBRARY_DIR, topdown=False):
# setuptools is including __pycache__ for some reason (#1605)
if root.endswith('/__pycache__'):
remove_dirs.append(root)
remove_dirs.extend(
root
for root, _dirs, _files in os.walk(LIBRARY_DIR, topdown=False)
if root.endswith('/__pycache__')
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

This removes the following comments ( why? ):

# setuptools is including __pycache__ for some reason (#1605)

Comment on lines -25 to +27
node = nodes.reference(rawtext, utils.unescape(name),
refuri='{}?q={}'.format(base, name),
**options)
return node
return nodes.reference(
rawtext, utils.unescape(name), refuri=f'{base}?q={name}', **options
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function make_link_node refactored with the following changes:

for cls in (types.PeerUser, types.PeerChat, types.PeerChannel):
result = self.__dict__.get(utils.get_peer_id(cls(item)))
if result:
if result := self.__dict__.get(utils.get_peer_id(cls(item))):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function EntityCache.__getitem__ refactored with the following changes:

"""Ensures that the parent directory exists"""
parent = os.path.dirname(file_path)
if parent:
if parent := os.path.dirname(file_path):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ensure_parent_dir_exists refactored with the following changes:

Comment on lines -114 to +113
if force_retry and not (retries is None or retries < 0):
if force_retry and retries is not None and retries >= 0:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function retry_range refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

return coro
else:
return loop.run_until_complete(coro)
return coro if loop.is_running() else loop.run_until_complete(coro)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _syncify_wrap.syncified refactored with the following changes:

if (
not name.startswith('_') or name == '__call__'
) and inspect.iscoroutinefunction(getattr(t, name)):
_syncify_wrap(t, name)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function syncify refactored with the following changes:

if isinstance(entity, types.User):
if entity.last_name and entity.first_name:
return '{} {}'.format(entity.first_name, entity.last_name)
return f'{entity.first_name} {entity.last_name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_display_name refactored with the following changes:

Comment on lines -138 to +140
raise TypeError('Cannot cast {} to any kind of {}.'.format(
type(entity).__name__, target))
raise TypeError(
f'Cannot cast {type(entity).__name__} to any kind of {target}.'
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _raise_cast_fail refactored with the following changes:

Comment on lines -479 to +490
else:
attrs, mime = get_attributes(
media,
attributes=attributes,
force_document=force_document,
voice_note=voice_note,
video_note=video_note,
supports_streaming=supports_streaming
)
return types.InputMediaUploadedDocument(
file=media, mime_type=mime, attributes=attrs, force_file=force_document,
ttl_seconds=ttl)
attrs, mime = get_attributes(
media,
attributes=attributes,
force_document=force_document,
voice_note=voice_note,
video_note=video_note,
supports_streaming=supports_streaming
)
return types.InputMediaUploadedDocument(
file=media, mime_type=mime, attributes=attrs, force_file=force_document,
ttl_seconds=ttl)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_input_media refactored with the following changes:

pass

raise TypeError('Invalid message type: {}'.format(type(message)))
raise TypeError(f'Invalid message type: {type(message)}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_message_id refactored with the following changes:

Comment on lines -638 to +650
if getattr(file, 'seekable', None):
seekable = file.seekable()
else:
seekable = False

seekable = file.seekable() if getattr(file, 'seekable', None) else False
if not seekable:
return None

pos = stream.tell()
filename = getattr(file, 'name', '')

parser = hachoir.parser.guess.guessParser(hachoir.stream.InputIOStream(
stream,
source='file:' + filename,
tags=[],
filename=filename
))
parser = hachoir.parser.guess.guessParser(
hachoir.stream.InputIOStream(
stream, source=f'file:{filename}', tags=[], filename=filename
)
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_metadata refactored with the following changes:

Comment on lines -684 to +682
m = _get_metadata(file)
if m:
if m := _get_metadata(file):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_attributes refactored with the following changes:

Comment on lines -843 to +837
return ('.' + kind) if kind else ''
return f'.{kind}' if kind else ''
elif isinstance(file, io.IOBase) and not isinstance(file, io.TextIOBase) and file.seekable():
kind = imghdr.what(file)
return ('.' + kind) if kind is not None else ''
return f'.{kind}' if kind is not None else ''
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_extension refactored with the following changes:

Comment on lines -860 to +851
if match:
return True
else:
return isinstance(resolve_bot_file_id(file), types.Photo)
return True if match else isinstance(resolve_bot_file_id(file), types.Photo)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_image refactored with the following changes:

Comment on lines -828 to +835
raise ValueError(
'No such action "{}"'.format(action)) from None
raise ValueError(f'No such action "{action}"') from None
elif not isinstance(action, types.TLObject) or action.SUBCLASS_OF_ID != 0x20b2cc21:
# 0x20b2cc21 = crc32(b'SendMessageAction')
if isinstance(action, type):
raise ValueError('You must pass an instance, not the class')
else:
raise ValueError('Cannot use {} as action'.format(action))
raise ValueError(f'Cannot use {action} as action')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ChatMethods.action refactored with the following changes:

Comment on lines -119 to +120
for entity in entities:
peers.append(types.InputDialogPeer(
await self.client.get_input_entity(entity)))

peers.extend(types.InputDialogPeer(
await self.client.get_input_entity(entity)) for entity in entities)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _DraftsIter._init refactored with the following changes:

Comment on lines -313 to +311
if not entity or utils.is_list_like(entity):
return items
else:
return items[0]
return items if not entity or utils.is_list_like(entity) else items[0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DialogMethods.get_drafts refactored with the following changes:

Comment on lines -383 to +382
if not utils.is_list_like(entity):
entities = [await self.get_input_entity(entity)]
else:
entities = await asyncio.gather(
*(self.get_input_entity(x) for x in entity))
entities = (
await asyncio.gather(*(self.get_input_entity(x) for x in entity))
if utils.is_list_like(entity)
else [await self.get_input_entity(entity)]
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DialogMethods.edit_folder refactored with the following changes:

Comment on lines -446 to +441
if isinstance(entity, types.Chat):
deactivated = entity.deactivated
else:
deactivated = False

deactivated = entity.deactivated if isinstance(entity, types.Chat) else False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DialogMethods.delete_dialog refactored with the following changes:

Comment on lines -259 to +282
if not hasattr(entity, 'chat_photo'):
return None

return await self._download_photo(
entity.chat_photo, file, date=None,
thumb=thumb, progress_callback=None
)

for attr in ('username', 'first_name', 'title'):
possible_names.append(getattr(entity, attr, None))
) if hasattr(entity, 'chat_photo') else None
possible_names.extend(
getattr(entity, attr, None)
for attr in ('username', 'first_name', 'title')
)

photo = entity.photo

if isinstance(photo, (types.UserProfilePhoto, types.ChatPhoto)):
dc_id = photo.dc_id
loc = types.InputPeerPhotoFileLocation(
peer=await self.get_input_entity(entity),
photo_id=photo.photo_id,
big=download_big
)
else:
if not isinstance(photo, (types.UserProfilePhoto, types.ChatPhoto)):
# It doesn't make any sense to check if `photo` can be used
# as input location, because then this method would be able
# to "download the profile photo of a message", i.e. its
# media which should be done with `download_media` instead.
return None

dc_id = photo.dc_id
loc = types.InputPeerPhotoFileLocation(
peer=await self.get_input_entity(entity),
photo_id=photo.photo_id,
big=download_big
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownloadMethods.download_profile_photo refactored with the following changes:

Comment on lines -401 to +405
if isinstance(media, types.MessageService):
if isinstance(message.action,
types.MessageActionChatEditPhoto):
media = media.photo

if isinstance(media, types.MessageMediaWebPage):
if isinstance(media.webpage, types.WebPage):
media = media.webpage.document or media.webpage.photo
if isinstance(media, types.MessageService) and isinstance(
message.action, types.MessageActionChatEditPhoto
):
media = media.photo

if isinstance(media, types.MessageMediaWebPage) and isinstance(
media.webpage, types.WebPage
):
media = media.webpage.document or media.webpage.photo
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownloadMethods.download_media refactored with the following changes:

Comment on lines -514 to +511
if not file_size:
part_size_kb = 64 # Reasonable default
else:
part_size_kb = utils.get_appropriated_part_size(file_size)

part_size_kb = utils.get_appropriated_part_size(file_size) if file_size else 64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownloadMethods._download_file refactored with the following changes:

This removes the following comments ( why? ):

# Reasonable default

Comment on lines -849 to +842
possible_names.append('{} - {}'.format(
attr.performer, attr.title
))
possible_names.append(f'{attr.performer} - {attr.title}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownloadMethods._get_kind_and_names refactored with the following changes:

Comment on lines -1038 to +1029
result = os.path.join(directory, '{} ({}){}'.format(name, i, ext))
result = os.path.join(directory, f'{name} ({i}){ext}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownloadMethods._get_proper_filename refactored with the following changes:

Comment on lines -811 to -831
session = self._exported_sessions.get(cdn_redirect.dc_id)
if not session:
dc = await self._get_dc(cdn_redirect.dc_id, cdn=True)
session = self.session.clone()
await session.set_dc(dc.id, dc.ip_address, dc.port)
self._exported_sessions[cdn_redirect.dc_id] = session

self._log[__name__].info('Creating new CDN client')
client = TelegramBaseClient(
session, self.api_id, self.api_hash,
proxy=self._sender.connection.conn.proxy,
timeout=self._sender.connection.get_timeout()
)

# This will make use of the new RSA keys for this specific CDN.
#
# We won't be calling GetConfigRequest because it's only called
# when needed by ._get_dc, and also it's static so it's likely
# set already. Avoid invoking non-CDN methods by not syncing updates.
client.connect(_sync_updates=False)
return client
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TelegramBaseClient._get_cdn_client refactored with the following changes:

This removes the following comments ( why? ):

# when needed by ._get_dc, and also it's static so it's likely
# This will make use of the new RSA keys for this specific CDN.
# set already. Avoid invoking non-CDN methods by not syncing updates.
#
# We won't be calling GetConfigRequest because it's only called

Comment on lines -400 to +418
if not self._entity_cache.ensure_cached(update):
# We could add a lock to not fetch the same pts twice if we are
# already fetching it. However this does not happen in practice,
# which makes sense, because different updates have different pts.
if self._state_cache.update(update, check_only=True):
# If the update doesn't have pts, fetching won't do anything.
# For example, UpdateUserStatus or UpdateChatUserTyping.
try:
await self._get_difference(update, channel_id, pts_date)
except OSError:
pass # We were disconnected, that's okay
except errors.RPCError:
# There's a high chance the request fails because we lack
# the channel. Because these "happen sporadically" (#1428)
# we should be okay (no flood waits) even if more occur.
pass
except ValueError:
# There is a chance that GetFullChannelRequest and GetDifferenceRequest
# inside the _get_difference() function will end up with
# ValueError("Request was unsuccessful N time(s)") for whatever reasons.
pass
if not self._entity_cache.ensure_cached(
update
) and self._state_cache.update(update, check_only=True):
# If the update doesn't have pts, fetching won't do anything.
# For example, UpdateUserStatus or UpdateChatUserTyping.
try:
await self._get_difference(update, channel_id, pts_date)
except OSError:
pass # We were disconnected, that's okay
except errors.RPCError:
# There's a high chance the request fails because we lack
# the channel. Because these "happen sporadically" (#1428)
# we should be okay (no flood waits) even if more occur.
pass
except ValueError:
# There is a chance that GetFullChannelRequest and GetDifferenceRequest
# inside the _get_difference() function will end up with
# ValueError("Request was unsuccessful N time(s)") for whatever reasons.
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdateMethods._dispatch_update refactored with the following changes:

This removes the following comments ( why? ):

# already fetching it. However this does not happen in practice,
# We could add a lock to not fetch the same pts twice if we are
# which makes sense, because different updates have different pts.

Comment on lines -541 to +539
assert isinstance(channel_id, int), 'channel_id was {}, not int in {}'.format(type(channel_id), update)
assert isinstance(
channel_id, int
), f'channel_id was {type(channel_id)}, not int in {update}'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdateMethods._get_difference refactored with the following changes:

Comment on lines -598 to -628
try:
self._log[__name__].info(
'Asking for the current state after reconnect...')

# TODO consider:
# If there aren't many updates while the client is disconnected
# (I tried with up to 20), Telegram seems to send them without
# asking for them (via updates.getDifference).
#
# On disconnection, the library should probably set a "need
# difference" or "catching up" flag so that any new updates are
# ignored, and then the library should call updates.getDifference
# itself to fetch them.
#
# In any case (either there are too many updates and Telegram
# didn't send them, or there isn't a lot and Telegram sent them
# but we dropped them), we fetch the new difference to get all
# missed updates. I feel like this would be the best solution.

# If a disconnection occurs, the old known state will be
# the latest one we were aware of, so we can catch up since
# the most recent state we were aware of.
await self.catch_up()

self._log[__name__].info('Successfully fetched missed updates')
except errors.RPCError as e:
self._log[__name__].warning('Failed to get missed updates after '
'reconnect: %r', e)
except Exception:
self._log[__name__].exception(
'Unhandled exception while getting update difference after reconnect')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdateMethods._handle_auto_reconnect refactored with the following changes:

This removes the following comments ( why? ):

# didn't send them, or there isn't a lot and Telegram sent them
# itself to fetch them.
# but we dropped them), we fetch the new difference to get all
# ignored, and then the library should call updates.getDifference
# If a disconnection occurs, the old known state will be
# difference" or "catching up" flag so that any new updates are
# the most recent state we were aware of.
# If there aren't many updates while the client is disconnected
# the latest one we were aware of, so we can catch up since
# missed updates. I feel like this would be the best solution.
# In any case (either there are too many updates and Telegram
# On disconnection, the library should probably set a "need
# TODO consider:
#
# asking for them (via updates.getDifference).
# (I tried with up to 20), Telegram seems to send them without

else:
captions = [caption]

captions = caption if utils.is_list_like(caption) else [caption]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UploadMethods.sendfile refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Mar 18, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.11%.

Quality metrics Before After Change
Complexity 17.03 🙂 16.30 🙂 -0.73 👍
Method Length 62.19 🙂 61.99 🙂 -0.20 👍
Working memory 10.41 😞 10.55 😞 0.14 👎
Quality 57.18% 🙂 57.29% 🙂 0.11% 👍
Other metrics Before After Change
Lines 20870 20587 -283
Changed files Quality Before Quality After Quality Change
setup.py 38.31% 😞 39.31% 😞 1.00% 👍
readthedocs/custom_roles.py 80.76% ⭐ 83.53% ⭐ 2.77% 👍
telethon/entitycache.py 64.15% 🙂 63.99% 🙂 -0.16% 👎
telethon/helpers.py 75.67% ⭐ 74.60% 🙂 -1.07% 👎
telethon/password.py 58.67% 🙂 58.47% 🙂 -0.20% 👎
telethon/statecache.py 84.19% ⭐ 82.51% ⭐ -1.68% 👎
telethon/sync.py 87.36% ⭐ 88.78% ⭐ 1.42% 👍
telethon/utils.py 57.43% 🙂 57.66% 🙂 0.23% 👍
telethon/client/account.py 83.31% ⭐ 83.14% ⭐ -0.17% 👎
telethon/client/auth.py 46.16% 😞 46.16% 😞 0.00%
telethon/client/chats.py 45.81% 😞 45.88% 😞 0.07% 👍
telethon/client/dialogs.py 58.37% 🙂 58.12% 🙂 -0.25% 👎
telethon/client/downloads.py 52.35% 🙂 53.15% 🙂 0.80% 👍
telethon/client/messageparse.py 30.18% 😞 29.10% 😞 -1.08% 👎
telethon/client/messages.py 42.92% 😞 43.12% 😞 0.20% 👍
telethon/client/telegrambaseclient.py 59.38% 🙂 58.72% 🙂 -0.66% 👎
telethon/client/updates.py 59.25% 🙂 59.53% 🙂 0.28% 👍
telethon/client/uploads.py 30.08% 😞 31.37% 😞 1.29% 👍
telethon/client/users.py 41.38% 😞 41.37% 😞 -0.01% 👎
telethon/crypto/aes.py 59.07% 🙂 59.22% 🙂 0.15% 👍
telethon/crypto/factorization.py 44.83% 😞 46.06% 😞 1.23% 👍
telethon/crypto/libssl.py 61.36% 🙂 61.67% 🙂 0.31% 👍
telethon/crypto/rsa.py 87.03% ⭐ 87.58% ⭐ 0.55% 👍
telethon/errors/init.py 69.37% 🙂 65.25% 🙂 -4.12% 👎
telethon/errors/common.py 81.45% ⭐ 81.10% ⭐ -0.35% 👎
telethon/errors/rpcbaseerrors.py 73.80% 🙂 72.88% 🙂 -0.92% 👎
telethon/events/album.py 80.28% ⭐ 80.07% ⭐ -0.21% 👎
telethon/events/callbackquery.py 76.56% ⭐ 76.73% ⭐ 0.17% 👍
telethon/events/chataction.py 66.21% 🙂 65.91% 🙂 -0.30% 👎
telethon/events/common.py 79.72% ⭐ 79.70% ⭐ -0.02% 👎
telethon/events/messagedeleted.py 82.87% ⭐ 82.95% ⭐ 0.08% 👍
telethon/events/messageread.py 80.46% ⭐ 80.51% ⭐ 0.05% 👍
telethon/events/newmessage.py 64.15% 🙂 64.53% 🙂 0.38% 👍
telethon/events/raw.py 80.15% ⭐ 81.43% ⭐ 1.28% 👍
telethon/extensions/binaryreader.py 84.91% ⭐ 84.41% ⭐ -0.50% 👎
telethon/extensions/html.py 40.18% 😞 41.03% 😞 0.85% 👍
telethon/extensions/markdown.py 29.41% 😞 27.32% 😞 -2.09% 👎
telethon/network/authenticator.py 20.83% ⛔ 20.82% ⛔ -0.01% 👎
telethon/network/mtprotosender.py 63.61% 🙂 63.31% 🙂 -0.30% 👎
telethon/network/mtprotostate.py 77.59% ⭐ 77.83% ⭐ 0.24% 👍
telethon/network/connection/connection.py 65.70% 🙂 67.22% 🙂 1.52% 👍
telethon/sessions/memory.py 71.31% 🙂 72.64% 🙂 1.33% 👍
telethon/sessions/sqlite.py 79.41% ⭐ 79.30% ⭐ -0.11% 👎
telethon/tl/tlobject.py 61.73% 🙂 66.70% 🙂 4.97% 👍
telethon/tl/core/gzippacked.py 92.80% ⭐ 94.85% ⭐ 2.05% 👍
telethon/tl/custom/chatgetter.py 83.11% ⭐ 83.31% ⭐ 0.20% 👍
telethon/tl/custom/conversation.py 73.01% 🙂 73.72% 🙂 0.71% 👍
telethon/tl/custom/inlinebuilder.py 38.06% 😞 38.26% 😞 0.20% 👍
telethon/tl/custom/inlineresults.py 88.07% ⭐ 84.84% ⭐ -3.23% 👎
telethon/tl/custom/message.py 62.05% 🙂 63.60% 🙂 1.55% 👍
telethon/tl/custom/qrlogin.py 79.23% ⭐ 79.08% ⭐ -0.15% 👎
telethon_examples/gui.py 67.06% 🙂 66.75% 🙂 -0.31% 👎
telethon_examples/interactive_telegram_client.py 49.16% 😞 47.46% 😞 -1.70% 👎
telethon_examples/payment.py 82.74% ⭐ 82.99% ⭐ 0.25% 👍
telethon_examples/quart_login.py 79.28% ⭐ 76.37% ⭐ -2.91% 👎
telethon_examples/replier.py 70.09% 🙂 70.95% 🙂 0.86% 👍
telethon_generator/docswriter.py 69.27% 🙂 69.60% 🙂 0.33% 👍
telethon_generator/generators/docs.py 27.03% 😞 27.75% 😞 0.72% 👍
telethon_generator/generators/errors.py 37.80% 😞 37.80% 😞 0.00%
telethon_generator/generators/tlobject.py 35.85% 😞 36.61% 😞 0.76% 👍
telethon_generator/parsers/errors.py 72.49% 🙂 72.39% 🙂 -0.10% 👎
telethon_generator/parsers/methods.py 70.10% 🙂 69.95% 🙂 -0.15% 👎
telethon_generator/parsers/tlobject/parser.py 47.92% 😞 45.16% 😞 -2.76% 👎
telethon_generator/parsers/tlobject/tlarg.py 65.63% 🙂 64.41% 🙂 -1.22% 👎
telethon_generator/parsers/tlobject/tlobject.py 65.18% 🙂 63.82% 🙂 -1.36% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
telethon_generator/generators/docs.py _write_html_pages 132 ⛔ 1385 ⛔ 25 ⛔ 1.94% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
telethon/client/messages.py _MessagesIter._init 52 ⛔ 429 ⛔ 23 ⛔ 6.43% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
telethon/client/telegrambaseclient.py TelegramBaseClient.__init__ 32 😞 524 ⛔ 33 ⛔ 9.46% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
telethon_examples/interactive_telegram_client.py InteractiveTelegramClient.run 54 ⛔ 477 ⛔ 17 ⛔ 9.55% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
telethon/client/messageparse.py MessageParseMethods._get_response_message 36 ⛔ 373 ⛔ 29 ⛔ 9.64% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants