-
Notifications
You must be signed in to change notification settings - Fork 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
Reget Develop #15
Reget Develop #15
Conversation
Signed-off-by: Code boys - 陈俊仁 <chen.junren@outlook.com>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Signed-off-by: 陈仁儿 <coding-cjr@outlook.com>
Signed-off-by: 陈仁儿 <coding-cjr@outlook.com>
Signed-off-by: 陈仁儿 <coding-cjr@outlook.com>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
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.
Hey @Chen-Junren - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Weather.py
Outdated
) | ||
|
||
|
||
def read_settings(filename: str = "settings.txt") -> dict: | ||
def print(*args: any, **kwargs: any) -> any: |
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.
issue (code_clarification): Overriding built-in 'print' function can lead to confusion and unexpected behaviors.
Consider using a different function name to avoid shadowing the built-in 'print' function.
Weather.py
Outdated
) | ||
else: | ||
warnings = "预 警:暂无预警信息" | ||
warnings = "预 警:暂无预警信息" | ||
dated = str(dates)[19:-1].replace(", ", "-") |
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.
issue (code_refinement): Using magic numbers for string slicing can lead to errors if the format changes.
Consider parsing the date with a date parsing function or library to handle different formats more robustly.
Weather.py
Outdated
debug = read_settings()['debug'] | ||
if debug: |
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.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression
)
debug = read_settings()['debug'] | |
if debug: | |
if debug := read_settings()['debug']: |
Weather.py
Outdated
os.system(file) | ||
|
||
|
||
def get_weather_1(city: str, code: str, dates: QtCore.QDate): |
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.
issue (code-quality): Low code quality found in get_weather_1 - 21% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
Weather.py
Outdated
layout1.addWidget(self.pushButton) | ||
self.pushButton.clicked.connect( | ||
lambda: copy( | ||
self, str("".join([f"{str(x)}\n" for x in infos]).replace(" ", "")) |
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.
suggestion (code-quality): Remove unnecessary casts to int, str, float or bool (remove-unnecessary-cast
)
self, str("".join([f"{str(x)}\n" for x in infos]).replace(" ", "")) | |
self, "".join([f"{str(x)}\n" for x in infos]).replace(" ", "") |
Weather.py
Outdated
self.label.setFixedSize(int(self.width() * 2 / 3), 280) | ||
self.label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) | ||
self.pushButton.clicked.connect( | ||
lambda: copy(self, str(weather_json).replace(" ", "")) |
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.
suggestion (code-quality): Remove unnecessary casts to int, str, float or bool (remove-unnecessary-cast
)
lambda: copy(self, str(weather_json).replace(" ", "")) | |
lambda: copy(self, weather_json.replace(" ", "")) |
Weather.py
Outdated
self.label.setFixedSize(int(self.width() * 2 / 3), 280) | ||
self.label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) | ||
self.pushButton.clicked.connect( | ||
lambda: copy(self, str(weather_json).replace(" ", "")) |
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.
suggestion (code-quality): Remove unnecessary casts to int, str, float or bool (remove-unnecessary-cast
)
lambda: copy(self, str(weather_json).replace(" ", "")) | |
lambda: copy(self, weather_json.replace(" ", "")) |
Weather.py
Outdated
""" | ||
super().__init__() | ||
layout = QtWidgets.QGridLayout() | ||
self.setWindowTitle(f"帮助") |
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.
suggestion (code-quality): Replace f-string with no interpolated values with string (remove-redundant-fstring
)
self.setWindowTitle(f"帮助") | |
self.setWindowTitle("帮助") |
Weather.py
Outdated
checkTime = read_settings().get("CheckTime") | ||
if checkTime: |
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.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression
)
checkTime = read_settings().get("CheckTime") | |
if checkTime: | |
if checkTime := read_settings().get("CheckTime"): |
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
No description provided.