Versatile Telegram bot designed for managing Docker containers, monitoring server status, and extending its functionality through a modular plugin system
Describe the bugstr.replace should be preferred to re.sub in get_disk_usage in psutil_adapter module
An re.sub call always performs an evaluation of the first argument as a regular expression, even if no regular expression features were used. This has a significant performance cost and therefore should be used with care.
When re.sub is used, the first argument should be a real regular expression. If it’s not the case, str.replace does exactly the same thing as re.sub without the performance drawback of the regex.
This rule raises an issue for each re.sub used with a simple string as first argument which doesn’t contains special regex character or pattern.
Describe the bug
str.replace
should be preferred tore.sub
inget_disk_usage
inpsutil_adapter
moduleAn re.sub call always performs an evaluation of the first argument as a regular expression, even if no regular expression features were used. This has a significant performance cost and therefore should be used with care.
When re.sub is used, the first argument should be a real regular expression. If it’s not the case, str.replace does exactly the same thing as re.sub without the performance drawback of the regex.
This rule raises an issue for each re.sub used with a simple string as first argument which doesn’t contains special regex character or pattern.