File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ def coverage(ctx: Context) -> None:
185185
186186
187187@duty
188- def test (ctx : Context , * cli_args : str , match : str = "" ) -> None :
188+ def test (ctx : Context , * cli_args : str , match : str = "" ) -> None : # noqa: PT028
189189 """Run the test suite.
190190
191191 Parameters:
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ dependencies = [
3232 " griffe>=0.49" ,
3333 " jinja2>=3.1.2" ,
3434 " mdformat>=0.7.16" ,
35+ # YORE: EOL 3.10: Remove line.
36+ " tomli>=2.0; python_version < '3.11'" ,
3537]
3638
3739[project .urls ]
Original file line number Diff line number Diff line change 11"""Load configuration."""
22
3+ from __future__ import annotations
4+
35import logging
6+ import sys
47from pathlib import Path
58from typing import Any
69
7- import tomllib
10+ # YORE: EOL 3.10: Replace block with line 2.
11+ if sys .version_info >= (3 , 11 ):
12+ import tomllib
13+ else :
14+ import tomli as tomllib
815
916logger = logging .getLogger (__name__ )
1017
11- PATHS = (
18+ CONFIG_FILE_PATHS = (
1219 Path (".config/griffe2md.toml" ),
1320 Path ("config/griffe2md.toml" ),
1421 Path ("pyproject.toml" ),
1522)
1623
1724
1825def _locate_config_file () -> Path | None :
19- for path in PATHS :
26+ for path in CONFIG_FILE_PATHS :
2027 if path .is_file ():
2128 return path
2229 return None
Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ def do_format_attribute(
284284def do_order_members (
285285 members : Sequence [Object | Alias ],
286286 order : Order ,
287- members_list : bool | list [str ] | None ,
287+ members_list : bool | list [str ] | None , # noqa: FBT001
288288) -> Sequence [Object | Alias ]:
289289 """Order members given an ordering method.
290290
@@ -415,7 +415,7 @@ def do_filter_objects(
415415@lru_cache (maxsize = 1 )
416416def _get_black_formatter () -> Callable [[str , int ], str ]:
417417 try :
418- from black import InvalidInput , Mode , format_str
418+ from black import InvalidInput , Mode , format_str # noqa: PLC0415
419419 except ModuleNotFoundError :
420420 logger .info ("Formatting signatures requires Black to be installed." )
421421 return lambda text , _ : text
Original file line number Diff line number Diff line change 66import pytest
77
88import griffe2md .cli
9- from griffe2md .config import PYPROJECT
10-
11-
12- @pytest .mark .parametrize (
13- "rel_path" ,
14- [
15- ".config/griffe2md.toml" ,
16- "config/griffe2md.toml" ,
17- "pyproject.toml" ,
18- ],
19- )
20- def test_load_config (tmpdir , rel_path : str ) -> None : # noqa: ANN001
9+ from griffe2md .config import CONFIG_FILE_PATHS
10+
11+
12+ @pytest .mark .parametrize ("rel_path" , CONFIG_FILE_PATHS )
13+ def test_load_config (tmpdir : Path , rel_path : Path ) -> None :
2114 """Test that config is loaded."""
2215 expected_config = {"dummy" : True }
2316 config_text = "dummy=true"
2417
2518 mock_write = Mock ()
2619
27- with tmpdir .as_cwd (), patch ("griffe2md.cli.write_package_docs" , mock_write ):
28- text = f"[tool.griffe2md]\n { config_text } " if rel_path == PYPROJECT else config_text
20+ with tmpdir .as_cwd (), patch ("griffe2md.cli.write_package_docs" , mock_write ): # type: ignore[attr-defined]
21+ text = f"[tool.griffe2md]\n { config_text } " if rel_path . name == "pyproject.toml" else config_text
2922 config_path = Path (tmpdir ) / rel_path
3023 config_path .parent .mkdir (parents = True , exist_ok = True )
3124 config_path .write_text (text , "utf-8" )
You can’t perform that action at this time.
0 commit comments