Skip to content
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

Clean up low-hanging fruit. #11

Open
wants to merge 2 commits into
base: multi
Choose a base branch
from

Conversation

francisdbillones
Copy link

Did a ton of refactors including reformatting to follow common formatting rules, unused variables, unsorted imports, etc.

@Jxck-S
Copy link
Owner

Jxck-S commented Feb 18, 2022

Looks like you know what you're doing, I'll have to check it out and test it Thanks a lot. Are you in the discord?

@francisdbillones
Copy link
Author

Not in the Discord, no. I'll join it right now.

@francisdbillones
Copy link
Author

Joined, this is my Discord ID 427783182948106241

socket.gaierror,
) as error_message:
print("Connection Error")
print(error_message)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be done better with the python stdlib logging module?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like Python's logging module. Maybe something like https://github.com/Delgan/loguru?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with the logging module? It's in stdlib and it's mostly the same as prints but more organised when in default settings

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found https://github.com/Delgan/loguru to be much more pleasing to use, I think the stdlib logging requires more configuration. To be honest both are suitable for this, loguru is just what I prefer

url += "/api/aircraft/v2/all"
else:
raise ValueError("Proxy enabled but no host")
headers = {"api-auth": API_KEY, "Accept-Encoding": "gzip"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding some whitespace in the below code could make it more readable

from datetime import datetime
import pytz
import os
import signal
import sys
import requests
from zipfile import ZipFile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these imports follow PEP8

features

stdlib

external

relative

style imports?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree! Actually didn't know that this was in PEP8. Nice to see it's formalized.

f.write(file_content.content)

except Exception as e:
raise e(f"Error getting{file_name} from {url}")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codacy says e is not callable and it is correct, it might help to either use

raise type(e)(msg) from e

or the better way is

raise CustomException(...) from e

import platform
import requests
import json
import re
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the imports thing but with all files perhaps


try:
photo_box = BROWSER.find_element_by_id("silhouette")
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the try except pass way of doing things is absolutely awful, either show the error to console or use except ErrorType to be more precise with what you expect

print(self)
# Ability to Remove old Map
import os
from colorama import Fore, Style
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats with the re-imports and localised imports? theres no circular imports as they are not relative
https://github.com/Jxck-S/plane-notify/pull/11/files#diff-dff727939aab7b094d4de98bb64ca4b1c86c99592f797e6a88f682843bd246c0R8

if os.path.isfile("lookup_route.py") and (
self.db_flags is None or not self.db_flags & 1
):
from lookup_route import lookup_route
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import looks so out of place and is unused, same with many others

hours, remainder = divmod(elapsed_time.total_seconds(), 3600)
minutes, seconds = divmod(remainder, 60)
print(
(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this second bracket pair necessary?

@@ -0,0 +1,107 @@
import requests
import json
import configparser
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is configparser ever used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants