cihai-cli 0.24.0__tar.gz → 0.26.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cihai-cli
3
- Version: 0.24.0
3
+ Version: 0.26.0
4
4
  Summary: Command line frontend for the cihai CJK language library
5
5
  Home-page: https://cihai-cli.git-pull.com
6
6
  License: MIT
@@ -25,7 +25,7 @@ Classifier: Topic :: Software Development :: Localization
25
25
  Classifier: Topic :: System :: Shells
26
26
  Classifier: Topic :: Utilities
27
27
  Requires-Dist: PyYAML
28
- Requires-Dist: cihai (>=0.29.0,<0.30.0)
28
+ Requires-Dist: cihai (>=0.31.0,<0.32.0)
29
29
  Project-URL: Bug Tracker, https://github.com/cihai/cihai-cli/issues
30
30
  Project-URL: Documentation, https://cihai-cli.git-pull.com
31
31
  Project-URL: Q & A, https://github.com/cihai/cihai-cli/discussions
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cihai-cli"
3
- version = "0.24.0"
3
+ version = "0.26.0"
4
4
  description = "Command line frontend for the cihai CJK language library"
5
5
  license = "MIT"
6
6
  authors = ["Tony Narlock <tony@git-pull.com>"]
@@ -58,14 +58,14 @@ Repository = "https://github.com/cihai/cihai-cli"
58
58
 
59
59
  [tool.poetry.dependencies]
60
60
  python = "^3.8"
61
- cihai = "~0.29.0"
61
+ cihai = "~0.31.0"
62
62
  PyYAML = "*"
63
63
 
64
64
  [tool.poetry.group.docs.dependencies]
65
65
  ### Docs ###
66
66
  sphinx = "*"
67
- gp-libs = "*"
68
67
  furo = "*"
68
+ gp-libs = "*"
69
69
  sphinx-autobuild = "*"
70
70
  sphinx-autodoc-typehints = "*"
71
71
  sphinx-argparse = "*"
@@ -81,6 +81,7 @@ docutils = "*"
81
81
  pytest = "*"
82
82
  pytest-rerunfailures = "*"
83
83
  pytest-watcher = "*"
84
+ gp-libs = "*"
84
85
 
85
86
  [tool.poetry.group.coverage.dependencies]
86
87
  ### Coverage ###
@@ -115,26 +116,38 @@ ignore_missing_imports = true
115
116
 
116
117
  [tool.ruff]
117
118
  target-version = "py38"
119
+
120
+ [tool.ruff.lint]
118
121
  select = [
119
122
  "E", # pycodestyle
120
123
  "F", # pyflakes
121
124
  "I", # isort
122
125
  "UP", # pyupgrade
126
+ "A", # flake8-builtins
123
127
  "B", # flake8-bugbear
124
128
  "C4", # flake8-comprehensions
129
+ "COM", # flake8-commas
130
+ "EM", # flake8-errmsg
125
131
  "Q", # flake8-quotes
126
132
  "PTH", # flake8-use-pathlib
127
133
  "SIM", # flake8-simplify
128
134
  "TRY", # Trycertatops
129
135
  "PERF", # Perflint
130
136
  "RUF", # Ruff-specific rules
137
+ "D", # pydocstyle
138
+ ]
139
+ ignore = [
140
+ "COM812", # missing trailing comma, ruff format conflict
131
141
  ]
132
142
 
133
- [tool.ruff.isort]
143
+ [tool.ruff.lint.isort]
134
144
  known-first-party = ["unihan_etl", "cihai"]
135
145
  combine-as-imports = true
136
146
 
137
- [tool.ruff.per-file-ignores]
147
+ [tool.ruff.lint.pydocstyle]
148
+ convention = "numpy"
149
+
150
+ [tool.ruff.lint.per-file-ignores]
138
151
  "*/__init__.py" = ["F401"]
139
152
 
140
153
  [tool.pytest.ini_options]
@@ -1,6 +1,7 @@
1
+ """Metadata for cihai_cli package."""
1
2
  __title__ = "cihai-cli"
2
3
  __package_name__ = "cihai_cli"
3
- __version__ = "0.24.0"
4
+ __version__ = "0.26.0"
4
5
  __description__ = "Command line frontend for the cihai CJK language library"
5
6
  __author__ = "Tony Narlock"
6
7
  __email__ = "tony@git-pull.com"
@@ -0,0 +1 @@
1
+ """Package for Cihai's CLI frontend."""
@@ -1,3 +1,4 @@
1
+ """CLI functionality for cihai-cli."""
1
2
  import argparse
2
3
  import logging
3
4
  import sys
@@ -30,6 +31,7 @@ INFO_SHORT_HELP = 'Get details on a CJK character, e.g. "好"'
30
31
 
31
32
 
32
33
  def create_parser() -> argparse.ArgumentParser:
34
+ """Create argparse for cihai-cli."""
33
35
  parser = argparse.ArgumentParser(prog="cihai")
34
36
  parser.add_argument(
35
37
  "--version",
@@ -57,7 +59,8 @@ def create_parser() -> argparse.ArgumentParser:
57
59
  info_parser = subparsers.add_parser("info", help=INFO_SHORT_HELP)
58
60
  create_info_subparser(info_parser)
59
61
  reverse_parser = subparsers.add_parser(
60
- "reverse", help='Search all info for character matches, e.g. "good"'
62
+ "reverse",
63
+ help='Search all info for character matches, e.g. "good"',
61
64
  )
62
65
  create_reverse_subparser(reverse_parser)
63
66
 
@@ -65,6 +68,8 @@ def create_parser() -> argparse.ArgumentParser:
65
68
 
66
69
 
67
70
  class CLILoadNamespace(argparse.Namespace):
71
+ """Typing for CLI namespace."""
72
+
68
73
  config_file: t.Optional[str]
69
74
  version: bool
70
75
  log_file: t.Optional[str]
@@ -75,8 +80,8 @@ def cli(_args: t.Optional[t.List[str]] = None) -> None:
75
80
 
76
81
  For help and example usage, see documentation:
77
82
 
78
- https://cihai-cli.git-pull.com and https://cihai.git-pull.com"""
79
-
83
+ https://cihai-cli.git-pull.com and https://cihai.git-pull.com
84
+ """
80
85
  parser = create_parser()
81
86
  args = parser.parse_args(_args, namespace=CLILoadNamespace())
82
87
 
@@ -100,6 +105,7 @@ def cli(_args: t.Optional[t.List[str]] = None) -> None:
100
105
 
101
106
 
102
107
  def create_info_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
108
+ """Create ``cihai info`` subparser."""
103
109
  parser.add_argument("char", metavar="<character>", help="Lookup term / character")
104
110
  parser.add_argument(
105
111
  "--all",
@@ -125,13 +131,14 @@ def command_info(c: Cihai, char: str, show_all: bool) -> None:
125
131
  continue
126
132
  attrs[str(col)] = value
127
133
  print(
128
- yaml.safe_dump(attrs, allow_unicode=True, default_flow_style=False).strip("\n")
134
+ yaml.safe_dump(attrs, allow_unicode=True, default_flow_style=False).strip("\n"),
129
135
  )
130
136
 
131
137
 
132
138
  def create_reverse_subparser(
133
139
  parser: argparse.ArgumentParser,
134
140
  ) -> argparse.ArgumentParser:
141
+ """Create ``cihai reverse`` subparser."""
135
142
  parser.add_argument("char", metavar="<character>", help="Lookup term / character")
136
143
  parser.add_argument(
137
144
  "--all",
@@ -159,20 +166,22 @@ def command_reverse(c: Cihai, char: str, show_all: bool) -> None:
159
166
  attrs[str(c)] = value
160
167
  print(
161
168
  yaml.safe_dump(attrs, allow_unicode=True, default_flow_style=False).strip(
162
- "\n"
163
- )
169
+ "\n",
170
+ ),
164
171
  )
165
172
  print("--------")
166
173
 
167
174
 
168
175
  def setup_logger(
169
- logger: t.Optional[logging.Logger] = None, level: str = "INFO"
176
+ logger: t.Optional[logging.Logger] = None,
177
+ level: str = "INFO",
170
178
  ) -> None:
171
- """Setup logging for CLI use.
172
-
173
- :param logger: instance of logger
174
- :type logger: :py:class:`Logger`
179
+ """Configure logging for CLI use.
175
180
 
181
+ Parameters
182
+ ----------
183
+ logger : :py:class:`Logger`
184
+ Instance of logger, if one set up.
176
185
  """
177
186
  if not logger:
178
187
  logger = logging.getLogger()
@@ -0,0 +1 @@
1
+ """Test package for cihai-cli."""
@@ -1,3 +1,4 @@
1
+ """Pytest configuration."""
1
2
  import pathlib
2
3
  import typing as t
3
4
  import zipfile
@@ -12,26 +13,31 @@ if t.TYPE_CHECKING:
12
13
 
13
14
  @pytest.fixture
14
15
  def tests_path() -> pathlib.Path:
16
+ """Return tests/ directory."""
15
17
  return pathlib.Path(__file__).parent
16
18
 
17
19
 
18
20
  @pytest.fixture
19
21
  def fixture_path(tests_path: pathlib.Path) -> pathlib.Path:
22
+ """Return tests/fixtures/ directory."""
20
23
  return tests_path / "fixtures"
21
24
 
22
25
 
23
26
  @pytest.fixture
24
27
  def test_config_file(fixture_path: pathlib.Path) -> pathlib.Path:
28
+ """Return test_config.yml file."""
25
29
  return fixture_path / "test_config.yml"
26
30
 
27
31
 
28
32
  @pytest.fixture
29
33
  def zip_path(tmp_path: pathlib.Path) -> pathlib.Path:
34
+ """Return Unihan.zip in temporary path."""
30
35
  return tmp_path / "Unihan.zip"
31
36
 
32
37
 
33
38
  @pytest.fixture
34
39
  def zip_file(zip_path: pathlib.Path, fixture_path: pathlib.Path) -> zipfile.ZipFile:
40
+ """Create and return ZipFile."""
35
41
  _files = []
36
42
  for f in UNIHAN_FILES:
37
43
  _files += [fixture_path / f]
@@ -44,8 +50,11 @@ def zip_file(zip_path: pathlib.Path, fixture_path: pathlib.Path) -> zipfile.ZipF
44
50
 
45
51
  @pytest.fixture
46
52
  def unihan_options(
47
- zip_file: zipfile.ZipFile, zip_path: pathlib.Path, tmp_path: pathlib.Path
53
+ zip_file: zipfile.ZipFile,
54
+ zip_path: pathlib.Path,
55
+ tmp_path: pathlib.Path,
48
56
  ) -> "UnihanOptions":
57
+ """Return UnihanOptions for fixture."""
49
58
  return {
50
59
  "source": zip_path,
51
60
  "work_dir": tmp_path,
@@ -55,4 +64,5 @@ def unihan_options(
55
64
 
56
65
  @pytest.fixture(scope="function")
57
66
  def tmpdb_file(tmpdir: pathlib.Path) -> pathlib.Path:
67
+ """Return test SQLite database."""
58
68
  return tmpdir / "test.db"
@@ -1,3 +1,4 @@
1
+ """CLI tests for cihai-cli."""
1
2
  import contextlib
2
3
  import pathlib
3
4
  import typing as t
@@ -16,6 +17,7 @@ def test_cli(
16
17
  capsys: pytest.CaptureFixture[str],
17
18
  monkeypatch: pytest.MonkeyPatch,
18
19
  ) -> None:
20
+ """Test basic cihai usage."""
19
21
  monkeypatch.chdir(tmp_path)
20
22
 
21
23
  with contextlib.suppress(SystemExit):
@@ -38,6 +40,7 @@ def test_cli_reflects_after_bootstrap(
38
40
  tmpdb_file: pathlib.Path,
39
41
  unihan_options: "UnihanOptions",
40
42
  ) -> None:
43
+ """High-level, integrative CLI-based test."""
41
44
  config = {
42
45
  "database": {"url": f"sqlite:///{tmpdb_file}s"},
43
46
  "unihan_options": {
@@ -48,7 +51,8 @@ def test_cli_reflects_after_bootstrap(
48
51
  }
49
52
  config_file = tmp_path / "config.yml"
50
53
  config_file.write_text(
51
- yaml.dump(config, default_flow_style=False), encoding="utf-8"
54
+ yaml.dump(config, default_flow_style=False),
55
+ encoding="utf-8",
52
56
  )
53
57
 
54
58
  try:
@@ -73,6 +77,7 @@ def test_cli_version(
73
77
  monkeypatch: pytest.MonkeyPatch,
74
78
  flag: str,
75
79
  ) -> None:
80
+ """Returns cihai-cli version."""
76
81
  try:
77
82
  cli([flag])
78
83
  except SystemExit:
File without changes
File without changes
File without changes
File without changes