Conversation
| if self.timer == None: | ||
| if self.timer is None: | ||
| return | ||
| self.timer.deinit() | ||
| if len(self.callbacks) > 0: | ||
| next_pointer = self.get_next_pointer(*self.get_current_pointer()) | ||
| if next_pointer == None: | ||
| if next_pointer is None: |
There was a problem hiding this comment.
Function SimpleCRONBase._first_step refactored with the following changes:
- Use x is None rather than x == None
| # We wait 5 seconds, if the lock is not removed then we emit an error. | ||
| from utime import sleep_ms | ||
| for i in range(5000): | ||
| for _ in range(5000): |
There was a problem hiding this comment.
Function SimpleCRONBase._wait_for_unlock_rw refactored with the following changes:
- Replace unused for index with underscore
| if self.timer == None: | ||
| if self.timer is None: | ||
| return | ||
| self.timer.deinit() | ||
| if len(self.callbacks) > 0: | ||
| next_pointer = self.get_next_pointer(*self.get_current_pointer()) | ||
| if next_pointer == None: | ||
| if next_pointer is None: |
There was a problem hiding this comment.
Function SimpleCRON._first_step refactored with the following changes:
- Use x is None rather than x == None
| # We wait 5 seconds, if the lock is not removed then we emit an error. | ||
| from utime import sleep_ms | ||
| for i in range(5000): | ||
| for _ in range(5000): |
There was a problem hiding this comment.
Function SimpleCRON._wait_for_unlock_rw refactored with the following changes:
- Replace unused for index with underscore
| time_steps_validated = [] | ||
| for time_step_key, (time_table_key, time_table_value) in enumerate(self.TIME_TABLE_KEYS.items()): | ||
| time_steps_validated.append( | ||
| self._validate_input( | ||
| time_table_key, | ||
| time_steps[time_step_key], | ||
| time_table_value | ||
| ) | ||
| time_steps_validated = [ | ||
| self._validate_input( | ||
| time_table_key, time_steps[time_step_key], time_table_value | ||
| ) | ||
| for time_step_key, (time_table_key, time_table_value) in enumerate( | ||
| self.TIME_TABLE_KEYS.items() | ||
| ) | ||
| ] |
There was a problem hiding this comment.
Function SimpleCRON.add refactored with the following changes:
- Convert for loop into list comprehension
| for level in range(max_level + 1): | ||
| for _ in range(max_level + 1): |
There was a problem hiding this comment.
Function SimpleCounter.get_next_pointer.get_first refactored with the following changes:
- Replace unused for index with underscore
| if _prev_data == None: | ||
| if _prev_data is None: | ||
| _prev_data = tuple() | ||
|
|
||
| if _time_table_node == None: | ||
| if _time_table_node is None: |
There was a problem hiding this comment.
Function SimpleCounter.list refactored with the following changes:
- Use x is None rather than x == None
| if not force: | ||
| if not self.callbacks[callback_name][1]: | ||
| raise Exception('This callback cannot be removed!') | ||
| if not force and not self.callbacks[callback_name][1]: | ||
| raise Exception('This callback cannot be removed!') | ||
|
|
||
| max_level = len(self.TIME_TABLE_KEYS) | ||
| # [ (time_table_part, <keys to check>, <current key>) ] | ||
| time_table_parts = [[self.time_table, list(self.time_table.keys()), None]] | ||
| while len(time_table_parts) > 0: | ||
| while time_table_parts: |
There was a problem hiding this comment.
Function SimpleCounter.remove refactored with the following changes:
- Merge nested if conditions
- Simplify sequence comparison
| lt = _localtime | ||
| else: | ||
| lt = localtime() | ||
| lt = _localtime if _localtime else localtime() |
There was a problem hiding this comment.
Function SimpleCRON.get_current_pointer refactored with the following changes:
- Replace if statement with if expression
| if current_pointer == next_time_pointer: | ||
| return False | ||
| return True | ||
| return current_pointer != next_time_pointer |
There was a problem hiding this comment.
Function SimpleCRON.next_step._next_step.is_the_same_callback refactored with the following changes:
- Simplify conditional into return statement
Branch
masterrefactored 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
masterbranch, then run: