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

Reget Develop #15

Merged
merged 13 commits into from
May 1, 2024
Merged

Reget Develop #15

merged 13 commits into from
May 1, 2024

Conversation

Chen-Junren
Copy link
Owner

No description provided.

Chen-Junren and others added 12 commits April 4, 2024 13:23
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>
Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Update gitignore

Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
Copy link

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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:
Copy link

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(", ", "-")
Copy link

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
Comment on lines 53 to 54
debug = read_settings()['debug']
if debug:
Copy link

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)

Suggested change
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):
Copy link

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)


ExplanationThe 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(" ", ""))
Copy link

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)

Suggested change
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(" ", ""))
Copy link

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)

Suggested change
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(" ", ""))
Copy link

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)

Suggested change
lambda: copy(self, str(weather_json).replace(" ", ""))
lambda: copy(self, weather_json.replace(" ", ""))

Weather.py Outdated
"""
super().__init__()
layout = QtWidgets.QGridLayout()
self.setWindowTitle(f"帮助")
Copy link

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)

Suggested change
self.setWindowTitle(f"帮助")
self.setWindowTitle("帮助")

Weather.py Outdated
Comment on lines 788 to 789
checkTime = read_settings().get("CheckTime")
if checkTime:
Copy link

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)

Suggested change
checkTime = read_settings().get("CheckTime")
if checkTime:
if checkTime := read_settings().get("CheckTime"):

Signed-off-by: 陈俊仁 <chen.junren@outlook.com>
@Chen-Junren Chen-Junren merged commit 405b0b5 into develop May 1, 2024
1 check passed
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

2 participants