-
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 IceBotYT/lacrosse_view #1
Conversation
headers = {"Authorization": f"Bearer {self.token}"} | ||
|
||
data: dict[str, Any] | ||
|
||
locations_url = ( | ||
"https://lax-gateway.appspot.com/" | ||
"_ah/api/lacrosseClient/v1.1/active-user/locations" | ||
) | ||
headers = {"Authorization": "Bearer " + self.token} | ||
|
||
data: dict[str, Any] | ||
|
||
if not self.websession: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get(locations_url, headers=headers) as response: | ||
if response.status != 200: | ||
raise HTTPError( | ||
"Failed to get locations, status code: " | ||
+ str(response.status) | ||
f"Failed to get locations, status code: {str(response.status)}" | ||
) | ||
|
||
data = await response.json() | ||
else: | ||
async with self.websession.get(locations_url, headers=headers) as response: | ||
if response.status != 200: | ||
raise HTTPError( | ||
"Failed to get locations, status code: " + str(response.status) | ||
f"Failed to get locations, status code: {str(response.status)}" | ||
) | ||
|
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 LaCrosse.get_locations
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
devices = list() | ||
headers = {"Authorization": "Bearer " + self.token} | ||
headers = {"Authorization": f"Bearer {self.token}"} | ||
|
||
sensors_url = f"https://lax-gateway.appspot.com/_ah/api/lacrosseClient/v1.1/active-user/location/{str(location.id)}/sensorAssociations?prettyPrint=false" | ||
|
||
sensors_url = ( | ||
"https://lax-gateway.appspot.com/" | ||
"_ah/api/lacrosseClient/v1.1/active-user/location/" | ||
+ str(location.id) | ||
+ "/sensorAssociations?prettyPrint=false" | ||
) | ||
if not self.websession: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get(sensors_url, headers=headers) as response: | ||
if response.status != 200: | ||
raise HTTPError( | ||
"Failed to get location, status code: " | ||
+ str(response.status) | ||
) | ||
raise HTTPError(f"Failed to get location, status code: {str(response.status)}") | ||
data = await response.json() | ||
else: | ||
async with self.websession.get(sensors_url, headers=headers) as response: | ||
if response.status != 200: | ||
raise HTTPError( | ||
"Failed to get location, status code: " + str(response.status) | ||
) | ||
raise HTTPError(f"Failed to get location, status code: {str(response.status)}") | ||
data = await response.json() | ||
|
||
aggregates = "ai.ticks.1" | ||
|
||
devices = [] |
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 LaCrosse.get_sensors
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Replace list() with [] (
list-literal
) - Use f-string instead of string concatenation [×8] (
use-fstring-for-concatenation
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
)
headers = {"Authorization": "Bearer " + self.token} | ||
headers = {"Authorization": f"Bearer {self.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 LaCrosse.logout
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
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
main
branch, then run: