Skip to content

Commit 93c4680

Browse files
committed
minimize redundant settings for ruff, restore black-compliant line length
1 parent 20819cb commit 93c4680

24 files changed

Lines changed: 310 additions & 205 deletions

pyproject.toml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -126,48 +126,12 @@ exclude_lines = [
126126
[tool.semantic_release]
127127
version_variable = "src/somesy/__init__.py:__version__"
128128

129-
[tool.ruff]
130-
line-length = 120
131-
indent-width = 4
132-
exclude = [
133-
".bzr",
134-
".direnv",
135-
".eggs",
136-
".git",
137-
".git-rewrite",
138-
".hg",
139-
".mypy_cache",
140-
".nox",
141-
".pants.d",
142-
".pytype",
143-
".ruff_cache",
144-
".svn",
145-
".tox",
146-
".venv",
147-
"__pypackages__",
148-
"_build",
149-
"buck-out",
150-
"build",
151-
"dist",
152-
"node_modules",
153-
"venv",
154-
]
155-
156-
157129
[tool.ruff.lint]
158-
select = ["E", "F", "I", "D", "B", "S", "W"]
159-
ignore = ["D203", "D212", "B008"]
130+
extend-select = ["I", "D", "B", "S", "W"]
131+
ignore = ["D203", "D213", "B008"]
160132

161133
[tool.ruff.lint.per-file-ignores]
162-
"__init__.py" = ["E402"]
163-
"**/{test/*}/*" = ["D", "S"]
164-
"**/{tests,docs,tools,scripts}/*" = ["ALL"]
165-
166-
[tool.ruff.format]
167-
quote-style = "double"
168-
indent-style = "space"
169-
skip-magic-trailing-comma = false
170-
line-ending = "auto"
134+
"**/{tests,docs}/*" = ["ALL"]
171135

172136
[tool.licensecheck]
173137
using = "poetry"

src/somesy/cff/writer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def __init__(
1818
path: Path,
1919
create_if_not_exists: bool = True,
2020
):
21-
"""
22-
Citation File Format (CFF) parser.
21+
"""Citation File Format (CFF) parser.
2322
2423
See [somesy.core.writer.ProjectMetadataWriter.__init__][].
2524
"""
@@ -33,7 +32,9 @@ def __init__(
3332
"repository": ["repository-code"],
3433
"maintainers": ["contact"],
3534
}
36-
super().__init__(path, create_if_not_exists=create_if_not_exists, direct_mappings=mappings)
35+
super().__init__(
36+
path, create_if_not_exists=create_if_not_exists, direct_mappings=mappings
37+
)
3738

3839
def _init_new_file(self):
3940
"""Initialize new CFF file."""
@@ -65,7 +66,9 @@ def save(self, path: Optional[Path] = None) -> None:
6566

6667
def _sync_authors(self, metadata: ProjectMetadata) -> None:
6768
"""Ensure that publication authors are added all into author list."""
68-
self.authors = self._sync_person_list(self.authors, metadata.publication_authors())
69+
self.authors = self._sync_person_list(
70+
self.authors, metadata.publication_authors()
71+
)
6972

7073
@staticmethod
7174
def _from_person(person: Person):

src/somesy/cli/init.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,39 @@ def config():
2626
input_file = Path(input_file)
2727
options = {
2828
"input_file": input_file,
29-
"no_sync_cff": not typer.confirm("Do you want to sync to a CFF file?", default=True),
29+
"no_sync_cff": not typer.confirm(
30+
"Do you want to sync to a CFF file?", default=True
31+
),
3032
}
3133
cff_file = typer.prompt("CFF file path", default="CITATION.cff")
3234
if cff_file is not None or cff_file != "":
3335
options["cff_file"] = cff_file
3436

35-
options["no_sync_pyproject"] = not typer.confirm("Do you want to sync to a pyproject.toml file?", default=True)
37+
options["no_sync_pyproject"] = not typer.confirm(
38+
"Do you want to sync to a pyproject.toml file?", default=True
39+
)
3640

3741
pyproject_file = typer.prompt("pyproject.toml file path", default="pyproject.toml")
3842
if pyproject_file is not None or pyproject_file != "":
3943
options["pyproject_file"] = pyproject_file
4044

41-
options["sync_package_json"] = typer.confirm("Do you want to sync to a package.json file?", default=False)
45+
options["sync_package_json"] = typer.confirm(
46+
"Do you want to sync to a package.json file?", default=False
47+
)
4248
package_json_file = typer.prompt("package.json file path", default="package.json")
4349
if package_json_file is not None or package_json_file != "":
4450
options["package_json_file"] = package_json_file
4551

46-
options["no_sync_codemeta"] = not typer.confirm("Do you want to sync to a codemeta.json file?", default=True)
52+
options["no_sync_codemeta"] = not typer.confirm(
53+
"Do you want to sync to a codemeta.json file?", default=True
54+
)
4755
codemeta_file = typer.prompt("codemeta.json file path", default="codemeta.json")
4856
if codemeta_file is not None or codemeta_file != "":
4957
options["codemeta_file"] = codemeta_file
5058

51-
options["show_info"] = typer.confirm("Do you want to show info about the sync process?")
59+
options["show_info"] = typer.confirm(
60+
"Do you want to show info about the sync process?"
61+
)
5262
options["verbose"] = typer.confirm("Do you want to show verbose logs?")
5363
options["debug"] = typer.confirm("Do you want to show debug logs?")
5464

@@ -63,4 +73,6 @@ def config():
6373
logger.debug(f"CLI options entered: {options}")
6474

6575
init_config(input_file, options)
66-
logger.info(f"[bold green]Input file is updated/created at {input_file}[/bold green]")
76+
logger.info(
77+
f"[bold green]Input file is updated/created at {input_file}[/bold green]"
78+
)

src/somesy/cli/sync.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,19 @@ def run_sync(somesy_input: SomesyInput):
123123
logger.info("[bold green]Synchronizing project metadata...[/bold green]")
124124
logger.info("Files to sync:")
125125
if not conf.no_sync_pyproject:
126-
logger.info(f" - [italic]pyproject.toml[/italic]:\t[grey]{conf.pyproject_file}[/grey]")
126+
logger.info(
127+
f" - [italic]pyproject.toml[/italic]:\t[grey]{conf.pyproject_file}[/grey]"
128+
)
127129
if not conf.no_sync_package_json:
128-
logger.info(f" - [italic]package.json[/italic]:\t[grey]{conf.package_json_file}[/grey]")
130+
logger.info(
131+
f" - [italic]package.json[/italic]:\t[grey]{conf.package_json_file}[/grey]"
132+
)
129133
if not conf.no_sync_cff:
130134
logger.info(f" - [italic]CITATION.cff[/italic]:\t[grey]{conf.cff_file}[/grey]")
131135
if not conf.no_sync_codemeta:
132-
logger.info(f" - [italic]codemeta.json[/italic]:\t[grey]{conf.codemeta_file}[/grey]\n")
136+
logger.info(
137+
f" - [italic]codemeta.json[/italic]:\t[grey]{conf.codemeta_file}[/grey]\n"
138+
)
133139
# ----
134140
sync_command(somesy_input)
135141
# ----

src/somesy/cli/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def wrap_exceptions(wrapped, instance, args, kwargs):
2727

2828

2929
def resolved_somesy_input(**cli_args) -> SomesyInput:
30-
"""
31-
Return a combined `SomesyInput` based on config file and passed CLI args.
30+
"""Return a combined `SomesyInput` based on config file and passed CLI args.
3231
3332
Will also adjust log levels accordingly.
3433
"""
@@ -52,5 +51,7 @@ def resolved_somesy_input(**cli_args) -> SomesyInput:
5251
# no cli log level -> set it according to the loaded configuration
5352
set_log_level(somesy_input.config.log_level())
5453

55-
logger.debug(f"Combined config (Defaults + File + CLI):\n{pretty_repr(somesy_input.config)}")
54+
logger.debug(
55+
f"Combined config (Defaults + File + CLI):\n{pretty_repr(somesy_input.config)}"
56+
)
5657
return somesy_input

src/somesy/codemeta/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,30 @@
1111

1212

1313
def collect_cm_sources(conf: SomesyConfig):
14-
"""
15-
Assemble list of inputs for codemetapy based on somesy config.
14+
"""Assemble list of inputs for codemetapy based on somesy config.
1615
1716
Returns files that are supported by both somesy and codemetapy and are enabled for somesy.
1817
"""
1918
cm_sources = []
20-
if not conf.no_sync_pyproject and conf.pyproject_file is not None and conf.pyproject_file.is_file():
19+
if (
20+
not conf.no_sync_pyproject
21+
and conf.pyproject_file is not None
22+
and conf.pyproject_file.is_file()
23+
):
2124
cm_sources.append(conf.pyproject_file)
2225
# NOTE: we don't add CFF directly, because it must be handled separately
2326
# NOTE: add other suitable somesy targets / codemeta sources (except CFF and codemeta) here
24-
if conf.no_sync_package_json and conf.package_json_file is not None and conf.package_json_file.is_file():
27+
if (
28+
conf.no_sync_package_json
29+
and conf.package_json_file is not None
30+
and conf.package_json_file.is_file()
31+
):
2532
cm_sources.append(conf.package_json_file)
2633
return cm_sources
2734

2835

2936
def update_codemeta(conf: SomesyConfig):
30-
"""
31-
Generate or update codemeta file based on sources that somesy supports.
37+
"""Generate or update codemeta file based on sources that somesy supports.
3238
3339
Returns True if file has been written, False if it was up to date.
3440
"""

src/somesy/codemeta/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434

3535

3636
def _localize_codemetapy_context(json):
37-
"""
38-
Prevent rdflib external context resolution by embedding it from a file.
37+
"""Prevent rdflib external context resolution by embedding it from a file.
3938
4039
The context is required to parse the JSON-LD correctly, fields with no
4140
context are ignored (not considered LD).
@@ -70,8 +69,7 @@ def _graph_from_cm_dict(graph_dict):
7069

7170

7271
def _graph_from_cm_file(file: Path) -> rdflib.Graph:
73-
"""
74-
Return loaded codemeta with localized context.
72+
"""Return loaded codemeta with localized context.
7573
7674
If file does not exist, returns `None` (to distinguish from existing but empty).
7775
"""
@@ -85,8 +83,7 @@ def _graph_from_cm_file(file: Path) -> rdflib.Graph:
8583

8684

8785
def update_codemeta_file(cm_file: Path, cm_dict: Dict) -> bool:
88-
"""
89-
Update codemeta file with graph in dict if it changed.
86+
"""Update codemeta file with graph in dict if it changed.
9087
9188
Returns True if the file update happened.
9289
"""

src/somesy/commands/init_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212

1313
def init_config(input_path: Path, options: dict) -> None:
14-
"""
15-
Initialize somesy configuration file.
14+
"""Initialize somesy configuration file.
1615
1716
Args:
1817
----

src/somesy/commands/sync.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def sync(somesy_input: SomesyInput):
1717
"""Sync selected metadata files with given input file."""
1818
conf, metadata = somesy_input.config, somesy_input.project
1919

20-
logger.debug(f"Project metadata: {pretty_repr(metadata.model_dump(exclude_defaults=True))}")
20+
logger.debug(
21+
f"Project metadata: {pretty_repr(metadata.model_dump(exclude_defaults=True))}"
22+
)
2123

2224
# update these only if they exist:
2325

@@ -41,8 +43,7 @@ def _sync_python(
4143
metadata: ProjectMetadata,
4244
pyproject_file: Path,
4345
):
44-
"""
45-
Sync pyproject.toml file using project metadata.
46+
"""Sync pyproject.toml file using project metadata.
4647
4748
Args:
4849
----
@@ -61,8 +62,7 @@ def _sync_cff(
6162
metadata: ProjectMetadata,
6263
cff_file: Path,
6364
):
64-
"""
65-
Sync CITATION.cff file using project metadata.
65+
"""Sync CITATION.cff file using project metadata.
6666
6767
Args:
6868
----
@@ -81,8 +81,7 @@ def _sync_package_json(
8181
metadata: ProjectMetadata,
8282
package_json_file: Path,
8383
):
84-
"""
85-
Sync package.json file using project metadata.
84+
"""Sync package.json file using project metadata.
8685
8786
Args:
8887
----

src/somesy/core/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414

1515
def discover_input(input_file: Optional[Path] = None) -> Path:
16-
"""
17-
Check given input file path. If not given, find somesy configuration file path from default list.
16+
"""Check given input file path. If not given, find somesy configuration file path from default list.
1817
1918
Args:
2019
----
@@ -52,8 +51,7 @@ def discover_input(input_file: Optional[Path] = None) -> Path:
5251

5352

5453
def get_input_content(path: Path, *, no_unwrap: bool = False) -> Dict[str, Any]:
55-
"""
56-
Read contents of a supported somesy input file.
54+
"""Read contents of a supported somesy input file.
5755
5856
Given a path to a TOML file, this function reads the file and returns its content as a TOMLDocument object.
5957
The function checks if the file is a valid somesy input file by checking its name and content.
@@ -86,7 +84,9 @@ def get_input_content(path: Path, *, no_unwrap: bool = False) -> Dict[str, Any]:
8684
if "tool" in input_content and "somesy" in input_content["tool"]:
8785
return input_content["tool"]["somesy"].unwrap()
8886
else:
89-
raise RuntimeError("No tool.somesy section found in pyproject.toml file!")
87+
raise RuntimeError(
88+
"No tool.somesy section found in pyproject.toml file!"
89+
)
9090

9191
if path.suffix == ".json" and "package" in path.name:
9292
with open(path, "r") as f:

0 commit comments

Comments
 (0)