Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

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

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jul 2, 2023

Branch main 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 main branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from noobzhax July 2, 2023 06:36
time_passed = 0

while time_passed < 5:
for time_passed in range(5):
Copy link
Author

Choose a reason for hiding this comment

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

Function topper refactored with the following changes:

Comment on lines -57 to +54
if value:
level = logging.INFO
else:
level = logging.WARNING
level = logging.INFO if value else logging.WARNING
Copy link
Author

Choose a reason for hiding this comment

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

Function verbosity_callback refactored with the following changes:

Comment on lines -44 to +49
def validate_delay(cls, val): # pylint: disable=no-self-use,no-self-argument
def validate_delay(cls, val): # pylint: disable=no-self-use,no-self-argument
"""Check if the delay used by user is values. If not, use closest logical values."""
if val not in range(0, 101):
logging.warning("delay must be within 0 to 100 seconds")
if val > 100:
val = 100
if val < 0:
val = 0
val = min(val, 100)
val = max(val, 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 PastSettings.validate_delay refactored with the following changes:

Comment on lines -70 to +83
tutorial_link = "Learn more http://bit.ly/configure-tgcf"

if CONFIG_FILE_NAME in os.listdir():
logging.info(f"{CONFIG_FILE_NAME} detected")
return 1
if os.getenv("TGCF_CONFIG"):
logging.info(f"env var {CONFIG_ENV_VAR_NAME} detected")
if not ".env" in os.listdir():
return 2
if not os.getenv("TGCF_CONFIG"):
return 0
logging.info(f"env var {CONFIG_ENV_VAR_NAME} detected")
if ".env" not in os.listdir():
return 2

tutorial_link = "Learn more http://bit.ly/configure-tgcf"

logging.warning(
f"If you can create files in your system,\
logging.warning(
f"If you can create files in your system,\
you should use tgcf.config.yml and not .env to define configuration {tutorial_link}"
)
sys.exit(1)
else:
return 0
)
sys.exit(1)
Copy link
Author

Choose a reason for hiding this comment

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

Function detect_config_type refactored with the following changes:

Comment on lines -104 to +101
if config_dict:
config = Config(**config_dict)
else:
config = Config()
config = Config(**config_dict) if config_dict else Config()
Copy link
Author

Choose a reason for hiding this comment

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

Function read_config refactored with the following changes:

  • Simplify conditional into switch-like form (switch)
  • Replace if statement with if expression (assign-if-exp)

Comment on lines -29 to +32
if not len(splitted) == 2:
if len(splitted) != 2:
splitted = text.split("\n", 1)
if not len(splitted) == 2:
return ""
if len(splitted) != 2:
return ""
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_args refactored with the following changes:

  • Simplify logical expression using De Morgan identities [×2] (de-morgan)
  • Hoist conditional out of nested conditional (hoist-if-from-if)

def display_forwards(forwards: List[Forward]) -> str:
"""Return a string that beautifully displays all current forwards."""
if len(forwards) == 0:
if not forwards:
Copy link
Author

Choose a reason for hiding this comment

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

Function display_forwards refactored with the following changes:


try:
plugin_module = import_module("tgcf.plugins." + plugin_id)
plugin_module = import_module(f"tgcf.plugins.{plugin_id}")
Copy link
Author

Choose a reason for hiding this comment

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

Function load_plugins refactored with the following changes:


async def modify(self, tm: TgcfMessage) -> TgcfMessage:
if not tm.file_type in ["gif", "video", "photo"]:
if tm.file_type not in ["gif", "video", "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 TgcfMark.modify refactored with the following changes:

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

async def modify(self, tm: TgcfMessage) -> TgcfMessage:

if not tm.file_type in ["photo"]:
if tm.file_type not in ["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 TgcfOcr.modify refactored with the following changes:

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

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