fix: 启用 ruff 做代码扫描

Description:

Log:
This commit is contained in:
mikigo 2024-02-02 13:27:22 +08:00
parent 2dbc2315a6
commit 63d9f1b09d
7 changed files with 132 additions and 15 deletions

View File

@ -1,2 +1,2 @@
[current]
tag = 2.4.5
tag = 2.4.6

View File

@ -1,17 +1,30 @@
# 版本更新记录
## 2.4.6dev
**New**
- 计算收集用例数量剔除 `skip``skipif` 的用例数量;[@mikigo](https://github.com/mikigo)
- 报告新增显示当前目录;[@mikigo](https://github.com/mikigo)
- 启用 Ruff 代码检查;[@mikigo](https://github.com/mikigo)
**Fix**
- 修复 `--noskip` 参数不能对 `skipif` 标签生效的问题;[@mikigo](https://github.com/mikigo)
- 修复 `dogtail` 获取 `application` 阻塞问题;感谢 **[@有志](https://github.com/zhao-george)**
## 2.4.52024/01/20
**Fix**
- 修复 1070 华为机型 Wayland 下报错:`Xlib.error.DisplayConnectionError`[@mikigo](https://github.com/mikigo)
- 增加csv多条件跳过用例功能多个以&&符号隔开即可;感谢 **[@有志](https://github.com/zhao-george)**
- 增加 `CSV` 多条件跳过用例功能,多个以 `&&` 符号隔开即可;感谢 **[@有志](https://github.com/zhao-george)**
## 2.4.42024/01/19
**New**
- 切换 `YouQu` 的正式域名为youqu.uniontech.com [@mikigo](https://github.com/mikigo)
- 切换 `YouQu` 的正式域名为:`youqu.uniontech.com` [@mikigo](https://github.com/mikigo)
- 重新构建了文档 UI 布局,对多个文档模块及文档内容进行了修改、调整、优化,增加了留言模块;[@mikigo](https://github.com/mikigo)
- 1070 窗管获取窗口信息的接口 `GetAllWindowStatesList` 换了调用逻辑YouQu 适配最新的接口;感谢 **[@泽铭](https://github.com/Jimijun)**

View File

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "youqu"
version = "2.4.5"
version = "2.4.6"
authors = [
{ name = "mikigo", email = "huangmingqiang@uniontech.com" },
]

90
ruff.toml Normal file
View File

@ -0,0 +1,90 @@
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
".idea",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
# Same as Black.
line-length = 100
indent-width = 4
# Assume Python 3.7
target-version = "py37"
[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = [
"E402",
"E711",
"E721",
"E722",
"E731",
"E712",
"F401",
"F403",
"F507",
"F541",
"F841",
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false
# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

View File

@ -1 +1 @@
from setting.globalconfig import GlobalConfig as conf
from setting.globalconfig import GlobalConfig as conf

View File

@ -19,6 +19,7 @@ from time import strftime
# pylint: disable=C0116,C0103,C0103,C0115,R0903
class GetCfg:
"""Gets the value in the configuration file"""
@ -45,6 +46,7 @@ class GetCfg:
class _GlobalConfig:
"""Basic framework global configuration"""
PROJECT_NAME = "YouQu"
class DirName:
@ -98,7 +100,6 @@ class _GlobalConfig:
TMPDIR = run_cfg.get("TMPDIR", default="/tmp/tmpdir")
SYS_THEME = run_cfg.get("SYS_THEME", default="deepin")
OCR_SERVER_HOST = run_cfg.get("OCR_SERVER_HOST", default="localhost")
OCR_PORT = run_cfg.get("OCR_PORT", default="8890")
OCR_NETWORK_RETRY = run_cfg.get("OCR_NETWORK_RETRY", default=1)
@ -149,19 +150,25 @@ class _GlobalConfig:
csv_cfg = GetCfg(GLOBAL_CONFIG_FILE_PATH, "csvctl")
PY_ID_TO_CSV = csv_cfg.get_bool("PY_ID_TO_CSV", default=False)
EXPORT_CSV_FILE = csv_cfg.get("EXPORT_CSV_FILE", default="")
EXPORT_CSV_HEARD = csv_cfg.get("EXPORT_CSV_HEARD", default="用例级别,用例类型,测试级别,是否跳过").replace(" ", "")
EXPORT_CSV_HEARD = csv_cfg.get(
"EXPORT_CSV_HEARD", default="用例级别,用例类型,测试级别,是否跳过"
).replace(" ", "")
# [log_cli]
log_cli = GetCfg(GLOBAL_CONFIG_FILE_PATH, "log_cli")
LOG_LEVEL = log_cli.get("LOG_LEVEL", default="INFO")
CLASS_NAME_STARTSWITH = tuple(
log_cli.get("CLASS_NAME_STARTSWITH", default="Assert").replace(" ", "").split(",")
log_cli.get("CLASS_NAME_STARTSWITH", default="Assert")
.replace(" ", "")
.split(",")
)
CLASS_NAME_ENDSWITH = tuple(
log_cli.get("CLASS_NAME_ENDSWITH", default="Widget").replace(" ", "").split(",")
)
CLASS_NAME_CONTAIN = tuple(
log_cli.get("CLASS_NAME_CONTAIN", default="ShortCut").replace(" ", "").split(",")
log_cli.get("CLASS_NAME_CONTAIN", default="ShortCut")
.replace(" ", "")
.split(",")
)
# ====================== 动态获取变量 ======================
@ -172,7 +179,7 @@ class _GlobalConfig:
HOST_IP = str(popen("hostname -I |awk '{print $1}'").read()).strip("\n").strip()
PRODUCT_INFO = popen("cat /etc/product-info").read()
VERSION = (OS_VERSION.get("EditionName[zh_CN]") or "") + (
OS_VERSION.get("MinorVersion") or ""
OS_VERSION.get("MinorVersion") or ""
)
# machine type
# e.g. x86_64
@ -201,9 +208,9 @@ class _GlobalConfig:
# 直接读环境变量XDG_SESSION_TYPE会有问题采用读文件的方式获取
DISPLAY_SERVER = (
popen("cat ~/.xsession-errors | grep XDG_SESSION_TYPE | head -n 1")
.read()
.split("=")[-1]
.strip("\n")
.read()
.split("=")[-1]
.strip("\n")
)
class DisplayServer:

View File

@ -48,10 +48,17 @@ def skipif_cpu_name(args: str):
"""
_skip_key = args.split("&")
for key in _skip_key:
if os.popen(
if (
os.popen(
f"echo '{GlobalConfig.PASSWORD}'| "
"sudo -S dmidecode -s system-product-name | awk '{print $NF}'"
).read().strip("\n").replace("-", "").replace("&", "") == key:
)
.read()
.strip("\n")
.replace("-", "")
.replace("&", "")
== key
):
return True
return False