Conversation
| elif job.pid is None: | ||
| print("'%s' is loaded but not currently running" % (job.label)) # noqa: T001 | ||
| else: | ||
| if job.pid is None: | ||
| print("'%s' is loaded but not currently running" % (job.label)) # noqa: T001 | ||
| else: | ||
| print("'%s' is loaded and currently running: PID = %s" % (job.label, job.pid)) # noqa: T001 | ||
| while job.pid is not None: | ||
| print("Alive! PID = %s" % job.pid) # noqa: T001 | ||
| job.refresh() | ||
| time.sleep(0.2) | ||
| print("'%s' is loaded and currently running: PID = %s" % (job.label, job.pid)) # noqa: T001 | ||
| while job.pid is not None: | ||
| print("Alive! PID = %s" % job.pid) # noqa: T001 | ||
| job.refresh() | ||
| time.sleep(0.2) |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif)
| v = open(os.path.join(os.path.dirname(__file__), "launchd", "__init__.py")) | ||
| VERSION = re.compile(r".*__version__ = \"(.*?)\"", re.S).match(v.read()).group(1) | ||
| v.close() | ||
| with open(os.path.join(os.path.dirname(__file__), "launchd", "__init__.py")) as v: | ||
| VERSION = re.compile(r".*__version__ = \"(.*?)\"", re.S).match(v.read()).group(1) |
There was a problem hiding this comment.
Lines 39-41 refactored with the following changes:
- Use
withwhen opening file to ensure closure (ensure-file-closed)
| if isinstance(arg, six.string_types): | ||
| if isinstance(arg, six.text_type): | ||
| cmd.append(arg.encode("utf-8")) | ||
| else: | ||
| cmd.append(arg) | ||
| else: | ||
| if not isinstance(arg, six.string_types): | ||
| raise ValueError("Argument is invalid: %r" % repr(arg)) | ||
| if isinstance(arg, six.text_type): | ||
| cmd.append(arg.encode("utf-8")) | ||
| else: | ||
| cmd.append(arg) |
There was a problem hiding this comment.
Function launchctl refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| else: | ||
| self._properties = convert_NSDictionary_to_dict(val) | ||
| # update pid and laststatus attributes | ||
| try: | ||
| self._pid = self._properties["PID"] | ||
| except KeyError: | ||
| self._pid = None | ||
| try: | ||
| self._laststatus = self._properties["LastExitStatus"] | ||
| except KeyError: | ||
| self._laststatus = None | ||
| self._properties = convert_NSDictionary_to_dict(val) | ||
| # update pid and laststatus attributes | ||
| try: | ||
| self._pid = self._properties["PID"] | ||
| except KeyError: | ||
| self._pid = None | ||
| try: | ||
| self._laststatus = self._properties["LastExitStatus"] | ||
| except KeyError: | ||
| self._laststatus = None |
There was a problem hiding this comment.
Function LaunchdJob.refresh refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 1.59%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
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! |
Branch
mainrefactored 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
mainbranch, then run:Help us improve this pull request!