-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #1
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
base: master
Are you sure you want to change the base?
Conversation
| if response.status_code == 200: | ||
| logging.info(f'Day report obtained for {day.isoformat()}') | ||
| day_report = json.loads(response.content.decode()) | ||
| for report in day_report: | ||
| if response.status_code != 200: | ||
| raise Exception(f'Day {day.isoformat()} problem.') | ||
| logging.info(f'Day report obtained for {day.isoformat()}') | ||
| day_report = json.loads(response.content.decode()) | ||
| for report in day_report: | ||
|
|
||
| # TODO in the future calculate the reported time and optimize the reports | ||
| date_reported = report['date'] | ||
| date_reported = f'{date_reported[6:]}-{date_reported[3:5]}-{date_reported[:2]}' | ||
| if report.get('tasks') and date_reported not in self.reported_days: | ||
| self.reported_days.append(date_reported) | ||
| logging.info(f'Day {date_reported} was previously reported') | ||
| # TODO in the future calculate the reported time and optimize the reports | ||
| date_reported = report['date'] | ||
| date_reported = f'{date_reported[6:]}-{date_reported[3:5]}-{date_reported[:2]}' | ||
| if report.get('tasks') and date_reported not in self.reported_days: | ||
| self.reported_days.append(date_reported) | ||
| logging.info(f'Day {date_reported} was previously reported') | ||
|
|
||
| self.reported_days = list(set(self.reported_days)) | ||
|
|
||
| else: | ||
| raise Exception(f'Day {day.isoformat()} problem.') | ||
| self.reported_days = list(set(self.reported_days)) |
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 WorkmeterClient.check_day_reporting refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| if response.status_code == 200: | ||
| logging.info(f'Calendar obtained for year {year}') | ||
| calendar = json.loads(response.content.decode()) | ||
| for day in calendar: | ||
| if ( | ||
| (expected_day := day['date'][:10]) and | ||
| until.isoformat() >= expected_day >= self.start_day.isoformat() and | ||
| expected_day not in self.holidays and | ||
| (expected_minutes := day.get('expected')) | ||
| ): | ||
| self.expected_days[day['date'][:10]] = expected_minutes | ||
| else: | ||
| if response.status_code != 200: | ||
| raise Exception(f'Error obtaining calendar for year "{year}".') | ||
| logging.info(f'Calendar obtained for year {year}') | ||
| calendar = json.loads(response.content.decode()) | ||
| for day in calendar: | ||
| if ( | ||
| (expected_day := day['date'][:10]) and | ||
| until.isoformat() >= expected_day >= self.start_day.isoformat() and | ||
| expected_day not in self.holidays and | ||
| (expected_minutes := day.get('expected')) | ||
| ): | ||
| self.expected_days[day['date'][:10]] = expected_minutes |
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 WorkmeterClient.get_expected_calendar refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| client.login(username=self.username, password=self.password) | ||
| self.assertEqual(client.token, 'test_token') | ||
| self.assertEqual(client.headers['Authorization'], f'Bearer test_token') | ||
| self.assertEqual(client.headers['Authorization'], 'Bearer test_token') |
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 ClientTest.test_login refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
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:Help us improve this pull request!