Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c173ac
change: add workarounds for ruff:COM812
ssato Aug 13, 2025
ce05f2f
fix: enable all rules by ruff linter by default
ssato Feb 2, 2026
0fce3d5
fix: rename tests.api.dump.test_basics.test_data to make its purpose …
ssato Feb 2, 2026
e018e66
fix: add configurations as workarounds to avoid some errors by ruff i…
ssato Feb 2, 2026
6bb1315
fix: corrections and workarounds for some errors by ruff linter
ssato Feb 2, 2026
f482a1d
fix: disable specific ruff rules to avoid conflicts
ssato Feb 2, 2026
cf0540e
fix: cleanups and workarunds for ruff
ssato Feb 2, 2026
a2a2a8f
fix: corrections for ruff errors in tests.api.load.single_load.*
ssato Feb 2, 2026
b020278
change: enable all ruff rules with minimal exceptions
ssato Feb 11, 2026
96822bf
fix: fix several ruff errors for setup.py
ssato Feb 11, 2026
7829fc1
fix: fix several ruff errors in docs/conf.py
ssato Feb 11, 2026
4a09cf8
change: update the copyright header
ssato Feb 11, 2026
387bdc4
fix: fix several ruff errors in anyconfig.api.*
ssato Feb 11, 2026
5c7b54d
fix: fix several ruff errors in anyconfig.backend.*
ssato Feb 11, 2026
8f1df2e
fix: fix several ruff errors in anyconfig.cli.*
ssato Feb 11, 2026
347cd8f
fix: fix several ruff errors in anyconfig.common.*
ssato Feb 11, 2026
9426947
fix: fix several ruff errors in anyconfig.pa*.*
ssato Feb 11, 2026
c26c219
fix: fix several ruff errors in anyconfig.dicts
ssato Feb 11, 2026
bd3d7fd
fix: fix several ruff errors in anyconfig.ioinfo.utils
ssato Feb 11, 2026
7b31937
fix: fix several ruff errors in anyconfig.ioinfo.*
ssato Feb 11, 2026
2d170db
fix: fix several ruff errors in anyconfig.processors.*
ssato Feb 11, 2026
2e233ce
fix: fix several ruff errors in tests.*
ssato Feb 11, 2026
53a090e
fix: fix several ruff errors in anyconfig.schema.*
ssato Feb 12, 2026
1a8a832
fix: fix several ruff errors in anyconfig.*, all the rest
ssato Feb 12, 2026
bbddcc7
enhancement: add lint-next target to prepare for ruff-by-default conf…
ssato Feb 12, 2026
a8b8767
fix: ruff error, TD006
ssato Feb 12, 2026
1ec8adc
fix: standardize the delimiter to '\n' across all platforms
ssato Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# -*- coding: utf-8 -*-
#
# pylint:disable=invalid-name
"""conf.py for sphinx."""
import sys
import pathlib
import sys

sys.path.insert(0, str(pathlib.Path(__file__).parent.resolve() / 'src'))
sys.path.insert(0, str(pathlib.Path(__file__).parent.resolve() / "src"))

extensions = [
'sphinx.ext.autodoc',
'sphinx_autodoc_typehints'
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
]
source_suffix = '.rst'
master_doc = 'index'
source_suffix = ".rst"
master_doc = "index"

project = u'python-anyconfig'
copyright = u'2021, Satoru SATOH <satoru.satoh@gmail.com>'
version = '0.10.0'
project = "python-anyconfig"
version = "3.13.11"
release = version

exclude_patterns = []

html_theme = 'default'
html_theme = "default"

autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"
134 changes: 73 additions & 61 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,79 +118,36 @@ disable = [
# .. seealso:: https://docs.astral.sh/ruff/settings/#top-level
[tool.ruff]
exclude = [
"tests/res/**/*.py",
"tests/__init__.py",
"tests/*/__init__.py",
"tests/*/*/__init__.py",
"tests/res/*/*/*/*.py",
"tests/res/*/*/*/*/*.py",
"tests/res/*/*/*/*/*/*.py",
"tests/res/*/*/*/*/*/*/*.py",
"tests/res/*/*/*/*/*/*/*/*.py",
]
src = [
"src",
"tests",
]

[tool.ruff.lint]
select = [
"ALL",
]
# This setting is intentional, although it breaks the rules.
ignore = [
"ANN002", # https://docs.astral.sh/ruff/rules/missing-type-args/
"ANN003", # https://docs.astral.sh/ruff/rules/missing-type-kwargs/
"ANN401", # https://docs.astral.sh/ruff/rules/any-type/
"D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
"D203", # Because it looks conflict with D211.
# https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
"D213", # Because it looks conflict with D212.
# https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports/
# https://github.com/PyCQA/isort/issues/2146

"ICN001", # https://docs.astral.sh/ruff/rules/unconventional-import-alias/
"TID252", # https://docs.astral.sh/ruff/rules/relative-imports/

"RUF022", # https://docs.astral.sh/ruff/rules/unsorted-dunder-all/

# .. note:: These are disabled until py39 support is dropped.
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation-union/
"UP045", # https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/
]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # pydocstyle
"DTZ", # flake8-datetimez
"E", # pycodestyle
"EM", # flake8-errmsg
"ERA", # flake8-eradicate
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PD", # flake8-vet
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # Pylint - Convention
"PLE", # Pylint - Error
"PLR", # Pylint - Refactor
"PLW", # Pylint - Warning
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RUF", # Ruff-specific rules
"RSE", # flake8-raise
"S", # flake8-bandit
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"T20", # flake8-print
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
"TID252", # https://docs.astral.sh/ruff/rules/relative-imports/
]

[tool.ruff.lint.extend-per-file-ignores]
Expand All @@ -203,6 +160,61 @@ select = [
# https://docs.astral.sh/ruff/rules/suspicious-xml-element-tree-usage/
"src/anyconfig/backend/xml/etree.py" = ["S314"]

"docs/*.py" = [
"INP001",
]

# TODO:
"src/anyconfig/backend/yaml/pyyaml.py" = [
"TD003", # https://docs.astral.sh/ruff/rules/missing-todo-link/
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/
]

"src/anyconfig/parser.py" = [
# https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/
"UP045",
]

"src/anyconfig/schema/datatypes.py" = [
"UP045",
]

# Ignored:
"tests/*.py" = [
# https://docs.astral.sh/ruff/rules/missing-type-function-argument/
"ANN001",
"D103", # https://docs.astral.sh/ruff/rules/undocumented-public-function/
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports/
# https://docs.astral.sh/ruff/rules/lowercase-imported-as-non-lowercase/
"N812",
"S101", # https://docs.astral.sh/ruff/rules/assert/
"TID252", # https://docs.astral.sh/ruff/rules/relative-imports/
]
"tests/*/*.py" = [
"ANN001",
"D103",
"I001",
"N812",
"S101",
"TID252",
]
"tests/*/*/*.py" = [
"ANN001",
"D103",
"I001",
"N812",
"S101",
"TID252",
]
"tests/*/*/*/*.py" = [
"ANN001",
"D103",
"I001",
"N812",
"S101",
"TID252",
]

#[tool.ruff.lint.flake8-annotations]
#[tool.ruff.lint.flake8-bandit]
#[tool.ruff.lint.flake8-bugbear]
Expand Down
27 changes: 15 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


# It might throw IndexError and so on.
VERSION = '0.1.0'
VERSION = "0.1.0"
VER_REG = re.compile(r"^__version__ = '([^']+)'")

for fpath in pathlib.Path('src').glob('**/__init__.py'):
for fpath in pathlib.Path("src").glob("**/__init__.py"):
for line in fpath.open():
match = VER_REG.match(line)
if match:
Expand All @@ -21,11 +21,13 @@
RELEASE = "1%{?dist}"
if os.environ.get("_SNAPSHOT_BUILD", None) is not None:
import datetime
RELEASE = RELEASE.replace('1',
datetime.datetime.now().strftime("%Y%m%d"))
RELEASE = RELEASE.replace(
"1",
datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y%m%d"),
)


def _replace(line):
def _replace(line: str) -> str:
"""Replace some strings in the RPM SPEC template."""
if "@VERSION@" in line:
return line.replace("@VERSION@", VERSION)
Expand All @@ -39,17 +41,18 @@ def _replace(line):
return line


class bdist_rpm(setuptools.command.bdist_rpm.bdist_rpm):
class bdist_rpm(setuptools.command.bdist_rpm.bdist_rpm): # noqa: N801
"""Override the default content of the RPM SPEC."""

spec_tmpl = pathlib.Path('pkg/package.spec.in').resolve()
spec_tmpl = pathlib.Path("pkg/package.spec.in").resolve()

def _make_spec_file(self):
def _make_spec_file(self) -> list[str]:
"""Generate the RPM SPEC file."""
return [_replace(line.rstrip()) for line in self.spec_tmpl.open()]


setuptools.setup(version=VERSION, cmdclass=dict(bdist_rpm=bdist_rpm),
data_files=[("share/man/man1", ["docs/anyconfig_cli.1"])])

# vim:sw=4:ts=4:et:
setuptools.setup(
version=VERSION,
cmdclass={"bdist_rpm": bdist_rpm},
data_files=[("share/man/man1", ["docs/anyconfig_cli.1"])],
)
6 changes: 3 additions & 3 deletions src/anyconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2012 - 2021 Satoru SATOH <satoru.satoh@gmail.com>
# Copyright (C) 2012 - 2026 Satoru SATOH <satoru.satoh gmail.com>
# SPDX-License-Identifier: MIT
#
# For 'anyconfig.open':
Expand Down Expand Up @@ -31,7 +31,7 @@
load_plugins, list_types, list_by_cid, list_by_type, list_by_extension,
findall, find,
try_query,
validate, is_valid, gen_schema
validate, is_valid, gen_schema,
)


Expand Down Expand Up @@ -67,7 +67,7 @@
"try_query",

# anyconfig.validate
"validate", "is_valid", "gen_schema" # validation APIs.
"validate", "is_valid", "gen_schema", # validation APIs.
]

# vim:sw=4:ts=4:et:
14 changes: 7 additions & 7 deletions src/anyconfig/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2012 - 2024 Satoru SATOH <satoru.satoh gmail.com>
# Copyright (C) 2012 - 2026 Satoru SATOH <satoru.satoh gmail.com>
# SPDX-License-Identifier: MIT
#
# pylint: disable=unused-import,import-error,invalid-name
Expand Down Expand Up @@ -87,10 +87,10 @@

from .datatypes import MaybeDataT
from ._dump import (
dump, dumps
dump, dumps,
)
from ._load import (
single_load, multi_load, load, loads
single_load, multi_load, load, loads,
)
from ._open import open # pylint: disable=redefined-builtin

Expand All @@ -99,7 +99,7 @@
from ..common import (
InDataT, InDataExT,
UnknownFileTypeError, UnknownParserTypeError,
UnknownProcessorTypeError, ValidationError
UnknownProcessorTypeError, ValidationError,
)
from ..dicts import (
MS_REPLACE, MS_NO_REPLACE, MS_DICTS, MS_DICTS_AND_LISTS, MERGE_STRATEGIES,
Expand All @@ -110,11 +110,11 @@
)
from ..parsers import (
load_plugins, list_types, list_by_cid, list_by_type, list_by_extension,
findall, find, MaybeParserT
findall, find, MaybeParserT,
)
from ..query import try_query
from ..schema import (
validate, is_valid, gen_schema
validate, is_valid, gen_schema,
)


Expand Down Expand Up @@ -160,5 +160,5 @@ def version() -> list[str]:
"try_query",

# anyconfig.validate
"validate", "is_valid", "gen_schema"
"validate", "is_valid", "gen_schema",
]
14 changes: 8 additions & 6 deletions src/anyconfig/api/_dump.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2012 - 2024 Satoru SATOH <satoru.satoh gmail.com>
# Copyright (C) 2012 - 2026 Satoru SATOH <satoru.satoh gmail.com>
# SPDX-License-Identifier: MIT
#
"""Provides the API to dump (serialize) objects."""
Expand All @@ -8,13 +8,15 @@
import typing

from .. import common, ioinfo, parsers

if typing.TYPE_CHECKING:
from . import datatypes
from .datatypes import ParserT


def dump(
data: common.InDataExT, out: ioinfo.PathOrIOInfoT,
ac_parser: parsers.MaybeParserT = None, **options
ac_parser: parsers.MaybeParserT = None,
**options: typing.Any,
) -> None:
"""Save ``data`` to ``out`` in specified or detected format.

Expand All @@ -31,13 +33,13 @@ def dump(
:raises: ValueError, UnknownProcessorTypeError, UnknownFileTypeError
"""
ioi = ioinfo.make(out)
psr: datatypes.ParserT = parsers.find(ioi, forced_type=ac_parser)
psr: ParserT = parsers.find(ioi, forced_type=ac_parser)
psr.dump(data, ioi, **options)


def dumps(
data: common.InDataExT, ac_parser: parsers.MaybeParserT = None,
**options
**options: typing.Any,
) -> str:
"""Return a str representation of ``data`` in specified format.

Expand All @@ -48,5 +50,5 @@ def dumps(
:return: Backend-specific string representation for the given data
:raises: ValueError, UnknownProcessorTypeError
"""
psr: datatypes.ParserT = parsers.find(None, forced_type=ac_parser)
psr: ParserT = parsers.find(None, forced_type=ac_parser)
return psr.dumps(data, **options)
Loading
Loading