Repository navigation
配置模块优化 - #4359
Merged
Merged
配置模块优化#4359
Conversation
Refactor configuration management to support environment variables and improve readability.
donghaiwang
approved these changes
Dec 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor configuration management to support environment variables and improve readability.
修改概述:
针对配置模块代码进行健壮性、可读性与可维护性三重优化
修改的详细描述
1.新增get_env_config工具函数,统一处理环境变量的读取、类型转换及失败回退逻辑,减少重复代码的同时提升配置加载的健壮性;
2.优化DETECTION_SOURCE类型转换逻辑(改用try-except),适配 “摄像头(整数)/ 视频路径(字符串)” 场景,避免原isdigit()的局限性;
经过了什么样的测试?
1.操作系统:Windows 10/11;
2.Python 版本:Python 3.11.9;
3.测试场景:验证环境变量 /.env配置加载、检测源(摄像头 / 视频路径)识别、配置类型转换的容错性,均运行正常无报错。
运行效果
动图、视频、截图等
