Files
DDNS/pyproject.toml
T
f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544)
* Initial plan

* feat: replace flake8 and black with ruff for unified linting and formatting

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor: use astral-sh/ruff-action@v3 for cleaner CI workflow

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* run format

* use fmt skip

* fix cloudflare

* fix cron

* fix cron

* fix fileio tests

* fix fileio tests

* fix cron

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Co-authored-by: New Future <NewFuture@users.noreply.github.com>
2025-08-09 11:29:35 +08:00

181 lines
5.0 KiB
TOML

#[build-system] #remove for python2
#requires = ["setuptools>=64.0", "wheel", "setuptools_scm"]
#build-backend = "setuptools.build_meta"
#[tool.setuptools_scm]
#local_scheme = "no-local-version"
[project]
name = "ddns"
dynamic = ["version"]
description = "Dynamic DNS client for multiple providers, supporting IPv4 and IPv6."
authors = [{ name = "NewFuture", email = "python@newfuture.cc" }]
readme = "README.md"
license = "MIT"
requires-python = ">=2.7"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"Topic :: Internet",
"Topic :: Internet :: Name Service (DNS)",
"Topic :: System :: Networking",
"Topic :: Software Development",
'Programming Language :: Python :: 2.7',
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
keywords = ["ddns", "ipv6", "ipv4", "dns", "dnspod", "alidns", "cloudflare"]
dependencies = []
[project.urls]
Homepage = "https://ddns.newfuture.cc"
Documentation = "https://ddns.newfuture.cc"
Repository = "https://github.com/NewFuture/DDNS"
"Bug Tracker" = "https://github.com/NewFuture/DDNS/issues"
Source = "https://github.com/NewFuture/DDNS"
[project.scripts]
ddns = "ddns.__main__:main"
# Optional dependencies
[project.optional-dependencies]
dev = [
"ruff",
"mock;python_version<'3.3'", # For Python 2.7 compatibility
]
# 可选的 pytest 支持(不是默认测试框架)
pytest = [
"pytest>=6.0",
"pytest-cov",
"mock;python_version<'3.3'",
]
# Setuptools configuration
[tool.setuptools]
platforms = ["any"]
packages = ["ddns", "ddns.provider", "ddns.util"]
package-dir= {"ddns" = "ddns"}
py-modules = ["ddns","ddns.provider", "ddns.util"]
#[tool.setuptools.packages.find]
#where = ["."]
[tool.setuptools.dynamic]
version = { attr = "ddns.__version__" }
# description = { attr = "ddns.__description__" }
# 测试配置 - 使用 unittest 作为默认测试框架
[tool.unittest]
start-directory = "tests"
pattern = "test_*.py"
# unittest 不需要额外配置,使用内置的 test discovery
# pytest 兼容配置(保持与 pytest 的兼容性)
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = ["-v", "--tb=short"]
# 确保 pytest 可以找到 test_base 模块
pythonpath = [".", "tests"]
# Ruff configuration - unified formatting and linting
[tool.ruff]
# Same line length as black was using
line-length = 120
# Ruff minimum supported version is py37, but project supports py27+
target-version = "py37"
exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".tox",
".venv",
"build",
"dist",
"__pycache__",
"*.egg-info",
]
[tool.ruff.lint]
# Enable pycodestyle (E, W), pyflakes (F), and mccabe (C) - same as flake8 defaults
# Deliberately exclude pyupgrade (UP) rules to maintain Python 2 compatibility
# (UP rules would convert u"" strings to "" which breaks py2 compatibility)
select = ["E", "W", "F", "C"]
# Same ignores as flake8 configuration, but using ruff rule codes
ignore = [
# "E203", # whitespace before ':' - not needed in ruff, formatter handles this
"E501", # line too long (handled by formatter)
"UP025", # unicode-kind-prefix (keep u"..." for Py2 compatibility)
]
# Same max complexity as flake8
mccabe = { max-complexity = 12 }
[tool.ruff.lint.per-file-ignores]
# Allow unused imports and redefined names in tests (same as flake8)
"tests/*" = ["F401", "F811"]
[tool.ruff.format]
line-ending = "auto"
indent-style = "space"
quote-style = "double"
skip-magic-trailing-comma = true # py2
docstring-code-format = true
docstring-code-line-length = "dynamic"
# 类型检查配置
[tool.pyright]
typeCheckingMode = "standard"
autoImportCompletions = true
autoFormatStrings = true
completeFunctionParens = true
supportAllPythonDocuments = true
importFormat = "relative"
generateWithTypeAnnotation = true
diagnosticMode = "workspace"
indexing = true
useLibraryCodeForTypes = true
# Coverage configuration (可选,仅在使用 pytest-cov 时需要)
# 要使用覆盖率报告,需要安装: pip install pytest pytest-cov
# 然后运行: pytest tests/ --cov=ddns --cov-report=term-missing
[tool.coverage.run]
source = ["ddns"]
omit = [
"*/tests/*",
"*/test_*",
"*/__pycache__/*",
"*/.*",
]
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
show_missing = true
precision = 2