-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery Starbot ⭐ refactored s-rigaud/pyTelloSDK #2
base: master
Are you sure you want to change the base?
Conversation
except (ModuleNotFoundError, ImportError): | ||
except ImportError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 35-45
refactored with the following changes:
- Remove redundant exceptions from an except clause [×2] (
remove-redundant-exception
) - Replace length-one exception tuple with exception [×2] (
simplify-single-exception-tuple
)
ip_net = ipaddress.ip_network(interface + '/24', strict=False) | ||
ip_net = ipaddress.ip_network(f'{interface}/24', strict=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function AbstractDrone.get_all_drones
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
if self.is_connected: | ||
flight_mode = flight_mode.lower().strip() | ||
if flight_mode == 'open pipe': | ||
self.flight_mode = OpenPipeMode(self) | ||
|
||
elif flight_mode == 'reactive': | ||
self.flight_mode = ReactiveMode(self) | ||
|
||
elif flight_mode == 'act from file': | ||
if options.get('filename') is None: | ||
self.end_connection = True | ||
raise TypeError("You forgot filename argument. \nSee : https://github.com/s-rigaud/dev-pyTelloSDK#flightmodes for help") | ||
else: | ||
self.flight_mode = ActFromFileMode(self, **options) | ||
|
||
elif flight_mode == 'act from list': | ||
if options.get('actions') is None: | ||
self.end_connection = True | ||
raise TypeError("You forgot actions argument. \nSee : https://github.com/s-rigaud/dev-pyTelloSDK#flightmodes for help") | ||
self.flight_mode = ActFromActionListMode(self, **options) | ||
|
||
elif flight_mode == 'picture mission': | ||
if NO_VIDEO_DECODER: | ||
raise NoVideoDecoderError("Be sure you have access to either av library or libh264decoder") | ||
self.flight_mode = PictureMission(self, **options) | ||
if not self.is_connected: | ||
return | ||
flight_mode = flight_mode.lower().strip() | ||
if flight_mode == 'act from file': | ||
if options.get('filename') is None: | ||
self.end_connection = True | ||
raise TypeError("You forgot filename argument. \nSee : https://github.com/s-rigaud/dev-pyTelloSDK#flightmodes for help") | ||
else: | ||
print('You enter an unrecognize flight mode') | ||
self.flight_mode = ActFromFileMode(self, **options) | ||
|
||
elif flight_mode == 'act from list': | ||
if options.get('actions') is None: | ||
self.end_connection = True | ||
raise TypeError("You forgot actions argument. \nSee : https://github.com/s-rigaud/dev-pyTelloSDK#flightmodes for help") | ||
self.flight_mode = ActFromActionListMode(self, **options) | ||
|
||
elif flight_mode == 'open pipe': | ||
self.flight_mode = OpenPipeMode(self) | ||
|
||
elif flight_mode == 'picture mission': | ||
if NO_VIDEO_DECODER: | ||
raise NoVideoDecoderError("Be sure you have access to either av library or libh264decoder") | ||
self.flight_mode = PictureMission(self, **options) | ||
elif flight_mode == 'reactive': | ||
self.flight_mode = ReactiveMode(self) | ||
|
||
else: | ||
print('You enter an unrecognize flight mode') | ||
self.end_connection = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function AbstractDrone.init_flight_mode
refactored with the following changes:
- Add guard clause (
last-if-guard
) - Simplify conditional into switch-like form [×2] (
switch
)
elif AV_AVAILABLE: | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function AbstractDrone.process_frame
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
@@ -52,7 +52,6 @@ def start(self, **options): | |||
self.swarm.end_connection = True | |||
self.swarm.command_socket.close() | |||
break | |||
# Useless escape chars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ReactiveMode.start
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
This removes the following comments ( why? ):
# Useless escape chars
data = data + self.queue[0] | ||
data += self.queue[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function VideoStream.read
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
print("Sending message: " + message) | ||
print(f"Sending message: {message}") | ||
except Exception as exc: | ||
print("Error sending: " + str(exc)) | ||
print(f"Error sending: {str(exc)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function send
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
print("Sending message: " + message) | ||
print(f"Sending message: {message}") | ||
except Exception as exc: | ||
print("Error sending: " + str(exc)) | ||
print(f"Error sending: {str(exc)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function send
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
print("Sending message: " + message) | ||
print(f"Sending message: {message}") | ||
except Exception as exc: | ||
print("Error sending: " + str(exc)) | ||
print(f"Error sending: {str(exc)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function send
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
print("Sending message: " + message) | ||
print(f"Sending message: {message}") | ||
except Exception as e: | ||
print("Error sending: " + str(e)) | ||
print(f"Error sending: {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function send
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
Kudos, SonarCloud Quality Gate passed! |
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: