Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

fix: 缩放不生效#856

Merged
IsHPDuwu merged 2 commits into
Class-Widgets:mainfrom
IsHPDuwu:feat/scale.0.6
Aug 13, 2025
Merged

fix: 缩放不生效#856
IsHPDuwu merged 2 commits into
Class-Widgets:mainfrom
IsHPDuwu:feat/scale.0.6

Conversation

@IsHPDuwu

Copy link
Copy Markdown
Member

No description provided.

@baiyao105 baiyao105 requested a review from ChimeYao-bot August 13, 2025 09:40
@github-actions

Copy link
Copy Markdown

🧪 静态检查结果

检查已完成(16933522832) - [🔄 PR检查],以下为结果

🕒 检查时间:2025-08-13 09:42:18 UTC / 2025-08-13 17:42:18 UTC+8
📝 触发提交信息f7a4245: "chore: 这没啥用"
📁 检查的文件数:2 个 - i18n_manager.py,main.py


🚨 严重错误

❌ PyLint 严重错误(点我展开)
main.py:800:8: E0606: Possibly using variable 'p_mgr' before assignment (possibly-used-before-assignment)
main.py:3197:30: E0606: Possibly using variable 'pygetwindow' before assignment (possibly-used-before-assignment)
❌ MyPy 严重错误(点我展开)
generate_speech.py:119: error: Returning Any from function declared to return "Optional[str]"  [no-any-return]
generate_speech.py:502: error: Call to untyped function "EdgeTTSProvider" in typed context  [no-untyped-call]
generate_speech.py:503: error: Call to untyped function "Pyttsx3Provider" in typed context  [no-untyped-call]
generate_speech.py:688: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
generate_speech.py:693: error: Incompatible types in assignment (expression has type "None", variable has type "str")  [assignment]
generate_speech.py:771: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
generate_speech.py:776: error: Incompatible types in assignment (expression has type "None", variable has type "str")  [assignment]
file.py:198: error: Incompatible default for argument "old_section" (default has type "None", argument has type "str")  [assignment]
file.py:198: error: Incompatible default for argument "old_key" (default has type "None", argument has type "str")  [assignment]
file.py:198: error: Incompatible default for argument "new_section" (default has type "None", argument has type "str")  [assignment]
file.py:199: error: Incompatible default for argument "new_key" (default has type "None", argument has type "str")  [assignment]
list_.py:117: error: Need type annotation for "not_exist_themes" (hint: "not_exist_themes: List[<type>] = ...")  [var-annotated]
list_.py:210: error: Missing return statement  [return]
list_.py:227: error: Returning Any from function declared to return "str"  [no-any-return]
list_.py:313: error: Argument 1 to "len" has incompatible type "Optional[Any]"; expected "Sized"  [arg-type]
list_.py:365: error: Returning Any from function declared to return "List[str]"  [no-any-return]
utils.py:77: error: Item "None" of "Optional[SingleInstanceGuard]" has no attribute "release"  [union-attr]
utils.py:116: error: Item "None" of "Optional[SingleInstanceGuard]" has no attribute "release"  [union-attr]
utils.py:241: error: Unsupported operand types for < ("datetime" and "float")  [operator]
utils.py:242: error: Unsupported operand types for >= ("datetime" and "float")  [operator]
utils.py:245: error: Argument "seconds" to "timedelta" has incompatible type "Union[float, datetime]"; expected "float"  [arg-type]
utils.py:524: error: Incompatible return value type (got "float", expected "int")  [return-value]
utils.py:598: error: Incompatible types in assignment (expression has type "datetime", variable has type "Optional[float]")  [assignment]
utils.py:632: error: Unsupported operand types for - ("float" and "None")  [operator]
utils.py:633: error: Returning Any from function declared to return "datetime"  [no-any-return]
utils.py:633: error: Unsupported operand types for + ("float" and "timedelta")  [operator]
utils.py:658: error: Incompatible return value type (got "float", expected "int")  [return-value]
utils.py:693: error: Incompatible return value type (got "Optional[float]", expected "Optional[datetime]")  [return-value]
utils.py:727: error: Unexpected keyword argument "config" for "TimeManagerInterface"  [call-arg]
conf.py:99: error: Incompatible types in assignment (expression has type "Dict[str, List[Any]]", variable has type "List[Any]")  [assignment]
conf.py:128: error: Argument 1 to "Path" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]
conf.py:173: error: Incompatible types in assignment (expression has type "Path", variable has type "str")  [assignment]
conf.py:174: error: Incompatible types in assignment (expression has type "Union[Path, str]", variable has type "str")  [assignment]
conf.py:177: error: Argument 1 to "Path" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]
conf.py:180: error: "str" has no attribute "stem"  [attr-defined]
conf.py:187: error: "str" has no attribute "parent"  [attr-defined]
conf.py:193: error: Argument 1 to "join" has incompatible type "Optional[str]"; expected "str"  [arg-type]
conf.py:206: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
conf.py:293: error: Need type annotation for "plugin_dict" (hint: "plugin_dict: Dict[<type>, <type>] = ...")  [var-annotated]
play_audio.py:71: error: Module "conf" does not explicitly export attribute "base_directory"  [attr-defined]
play_audio.py:97: error: Module "conf" does not explicitly export attribute "base_directory"  [attr-defined]
play_audio.py:107: error: Module "conf" does not explicitly export attribute "base_directory"  [attr-defined]
play_audio.py:181: error: Call to untyped function "AudioManager" in typed context  [no-untyped-call]
cses_mgr.py:50: error: Missing type parameters for generic type "Dict"  [type-arg]
cses_mgr.py:134: error: Need type annotation for "class_counter_dict" (hint: "class_counter_dict: Dict[<type>, <type>] = ...")  [var-annotated]
cses_mgr.py:135: error: Cannot determine type of "parts"  [has-type]
cses_mgr.py:136: error: Cannot determine type of "part_names"  [has-type]
cses_mgr.py:137: error: Cannot determine type of "parts"  [has-type]
cses_mgr.py:144: error: Cannot determine type of "timelines"  [has-type]
cses_mgr.py:145: error: Cannot determine type of "timelines"  [has-type]

📋 其他检查

🔍 PyLint 提示(点我展开)
************* Module i18n_manager
i18n_manager.py:30:0: C0325: Unnecessary parens after ':=' keyword (superfluous-parens)
i18n_manager.py:57:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:128:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:142:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:150:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:188:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:201:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:221:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:224:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:226:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:234:0: C0303: Trailing whitespace (trailing-whitespace)
i18n_manager.py:261:0: C0304: Final newline missing (missing-final-newline)
i18n_manager.py:30:20: W0622: Redefining built-in 'dir' (redefined-builtin)
i18n_manager.py:38:11: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:71:15: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:92:15: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:156:12: W0621: Redefining name 'app' from outer scope (line 259) (redefined-outer-name)
i18n_manager.py:155:12: W0621: Redefining name 'Path' from outer scope (line 6) (redefined-outer-name)
i18n_manager.py:204:15: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:155:12: W0404: Reimport 'Path' (imported line 6) (reimported)
i18n_manager.py:155:12: C0415: Import outside toplevel (pathlib.Path) (import-outside-toplevel)
i18n_manager.py:195:12: C0415: Import outside toplevel (list_) (import-outside-toplevel)
i18n_manager.py:196:12: C0415: Import outside toplevel (importlib) (import-outside-toplevel)
i18n_manager.py:222:15: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:214:16: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
i18n_manager.py:229:8: W0621: Redefining name 'app' from outer scope (line 259) (redefined-outer-name)
i18n_manager.py:247:15: W0718: Catching too general exception Exception (broad-exception-caught)
i18n_manager.py:182:16: W0201: Attribute 'current_language_widgets' defined outside __init__ (attribute-defined-outside-init)
i18n_manager.py:5:0: C0411: standard import "os" should be placed before third party imports "qfluentwidgets.FluentTranslator", "PyQt5.QtCore.QLocale", "PyQt5.QtWidgets.QApplication" (wrong-import-order)
i18n_manager.py:6:0: C0411: standard import "pathlib.Path" should be placed before third party imports "qfluentwidgets.FluentTranslator", "PyQt5.QtCore.QLocale", "PyQt5.QtWidgets.QApplication" (wrong-import-order)
i18n_manager.py:8:0: C0411: standard import "sys" should be placed before third party imports "qfluentwidgets.FluentTranslator", "PyQt5.QtCore.QLocale", "PyQt5.QtWidgets.QApplication", "loguru.logger" (wrong-import-order)
i18n_manager.py:9:0: C0411: standard import "json" should be placed before third party imports "qfluentwidgets.FluentTranslator", "PyQt5.QtCore.QLocale", "PyQt5.QtWidgets.QApplication", "loguru.logger" (wrong-import-order)
i18n_manager.py:10:0: C0411: standard import "datetime.datetime" should be placed before third party imports "qfluentwidgets.FluentTranslator", "PyQt5.QtCore.QLocale", "PyQt5.QtWidgets.QApplication", "loguru.logger" (wrong-import-order)
i18n_manager.py:10:0: W0611: Unused datetime imported from datetime (unused-import)
************* Module main
main.py:132:15: C0303: Trailing whitespace (trailing-whitespace)
main.py:156:57: C0303: Trailing whitespace (trailing-whitespace)
main.py:157:53: C0303: Trailing whitespace (trailing-whitespace)
main.py:158:26: C0303: Trailing whitespace (trailing-whitespace)
main.py:160:31: C0303: Trailing whitespace (trailing-whitespace)
main.py:247:0: C0303: Trailing whitespace (trailing-whitespace)
main.py:304:14: C0303: Trailing whitespace (trailing-whitespace)
main.py:357:80: C0303: Trailing whitespace (trailing-whitespace)
main.py:388:83: C0303: Trailing whitespace (trailing-whitespace)
main.py:435:0: W0311: Bad indentation. Found 36 spaces, expected 32 (bad-indentation)
main.py:461:53: C0303: Trailing whitespace (trailing-whitespace)
main.py:462:57: C0303: Trailing whitespace (trailing-whitespace)
main.py:463:57: C0303: Trailing whitespace (trailing-whitespace)
main.py:479:35: C0303: Trailing whitespace (trailing-whitespace)
🔍 MyPy 提示(点我展开)
file.py:198: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
file.py:198: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
file.py:199: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
file.py:199: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
utils.py:241: note: Right operand is of type "Union[float, datetime]"
utils.py:242: note: Right operand is of type "Union[float, datetime]"
utils.py:632: note: Right operand is of type "Optional[float]"
.venv/lib/python3.8/site-packages/mypy/typeshed/stdlib/builtins.pyi:110: note: "TimeManagerInterface" defined here
weather.py:684: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
weather.py:684: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
weather.py:1715: note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
weather.py:1715: note: Consider using "Mapping" instead, which is covariant in the value type
weather.py:1715: note: Perhaps you need a type annotation for "result"? Suggestion: "Dict[str, Optional[str]]"
weather.py:1718: note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
weather.py:1718: note: Consider using "Mapping" instead, which is covariant in the value type
weather.py:1718: note: Perhaps you need a type annotation for "result"? Suggestion: "Dict[str, Optional[str]]"
weather.py:2296: note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
weather.py:2296: note: Consider using "Mapping" instead, which is covariant in the value type
weather.py:2296: note: Perhaps you need a type annotation for "aqi_data"? Suggestion: "Dict[str, Optional[str]]"
weather.py:2338: note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
weather.py:2338: note: Consider using "Mapping" instead, which is covariant in the value type
weather.py:2338: note: Perhaps you need a type annotation for "aqi_data"? Suggestion: "Dict[str, Optional[str]]"
network_thread.py:460: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
network_thread.py:460: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
menu.py:1645: note: Possible overload variants:
menu.py:1645: note:     def setParent(self, parent: QWidget) -> None
menu.py:1645: note:     def setParent(self, parent: QWidget, f: Union[WindowFlags, WindowType]) -> None
menu.py:3402: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
menu.py:3402: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
menu.py:3411: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
menu.py:3411: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
main.py:1642: note: Right operand is of type "Optional[Any]"
main.py:3146: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
main.py:3146: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
Found 1003 errors in 16 files (checked 2 source files)

@IsHPDuwu IsHPDuwu merged commit 6d86a80 into Class-Widgets:main Aug 13, 2025
12 checks passed
@baiyao105 baiyao105 requested review from ChimeYao-bot and removed request for ChimeYao-bot August 13, 2025 10:51
ChimeYao-bot

This comment was marked as off-topic.

@baiyao105 baiyao105 requested a review from ChimeYao-bot August 13, 2025 11:28

@ChimeYao-bot ChimeYao-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ AI代码审查报告

总体评分: 80.0/100
审查状态: ✅ 通过

总结: 代码变更主要涉及QT缩放因子的设置位置调整,从main.py移动到i18n_manager.py,这是一个合理的重构。但仍有一些可以改进的地方。

📊 问题统计

  • ℹ️ Info: 3
  • ⚠️ Warning: 1

🤖 此审查由AI助手自动生成,详细评论请查看文件中的具体建议

Comment thread i18n_manager.py
@@ -254,6 +254,8 @@ def init_from_config(self):
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Warning: 没有对config_center.read_conf('General', 'scale')的返回值进行验证或异常处理

建议添加try-catch块处理可能的异常,并对返回值进行验证

Comment thread i18n_manager.py
@@ -254,6 +254,8 @@ def init_from_config(self):
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Info: 缺少对QT_SCALE_FACTOR环境变量的类型转换

建议添加float转换确保数值类型正确

Comment thread i18n_manager.py
@@ -254,6 +254,8 @@ def init_from_config(self):
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Info: 文件末尾缺少换行符

建议在文件末尾添加换行符

Comment thread main.py Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Info: scale_factor变量仍然保留但不再使用

建议移除scale_factor变量或保留用于日志记录

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants