hydev 6.0.0__tar.gz → 6.2.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.4
2
2
  Name: hydev
3
- Version: 6.0.0
3
+ Version: 6.2.0
4
4
  Summary: Common tooling and configuration for pythonic development
5
5
  Project-URL: Repository, https://gitlab.com/hoverhell/hydev
6
6
  Author-email: hoverhell <hoverhell@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hydev"
3
- version = "6.0.0"
3
+ version = "6.2.0"
4
4
  description = "Common tooling and configuration for pythonic development"
5
5
  authors = [{ name = "hoverhell", email = "hoverhell@gmail.com" }]
6
6
  requires-python = ">=3.11,<4"
@@ -0,0 +1,98 @@
1
+ [tool.hydev]
2
+ ignore_paths = [
3
+ "*.egg-info",
4
+ ".env",
5
+ ".git",
6
+ ".tox",
7
+ ".venv",
8
+ ".cache",
9
+ # # Enabling these would require support for root-folder filtering in all tool configs.
10
+ # "/build",
11
+ # "/dist",
12
+ ]
13
+
14
+ [tool.isort]
15
+ profile = "black"
16
+ default_section = "THIRDPARTY"
17
+ include_trailing_comma = true
18
+ use_parentheses = true
19
+ multi_line_output = 3
20
+
21
+ [tool.black]
22
+ line-length = 120
23
+
24
+ [tool.flake8]
25
+ max-line-length = 120
26
+ show-source = true
27
+ statistics = false
28
+ enable-extensions = ["G", "FS003"]
29
+ ignore = [
30
+ # If `flake8-future-import` is present, only require `from __future__ import annotations`.
31
+ "FI10", "FI11", "FI12", "FI13", "FI14", "FI15", "FI16", "FI17", "FI58",
32
+ # Prefer “line break before binary operator” over W504 “line break after binary operator”
33
+ "W503",
34
+ # Conflicts with `ruff`
35
+ "E203", # “E203 whitespace before ':'” on e.g. `lst[idx : idx + size]`
36
+ # Leave the line length checking to ruff
37
+ "E501", # "line too long"
38
+ # Disable "E704 multiple statements on one line (def)" because of `black`
39
+ # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html
40
+ "E704",
41
+ ]
42
+ per-file-ignores = [
43
+ "__init__.py:F401,F403", # “imported but unused”, “'import *' used”
44
+ ]
45
+
46
+ [tool.pytest.ini_options]
47
+ timeout = 5
48
+ xfail_strict = true
49
+ addopts = [
50
+ "--blockage",
51
+ "--blockage-http-whitelist=localhost,127.0.0.1",
52
+ "--strict-markers",
53
+ "--strict-config",
54
+ "--dup-fixtures",
55
+ # Output:
56
+ "--tb=short",
57
+ # Parallelism:
58
+ # "-n auto",
59
+ # "--boxed",
60
+ # Coverage:,
61
+ "--cov-branch",
62
+ "--cov-report=term-missing:skip-covered",
63
+ "--cov-report=html",
64
+ "--cov=src",
65
+ "--cov=tests",
66
+ ]
67
+ env = [
68
+ "RUN_ENV=tests",
69
+ ]
70
+
71
+
72
+ [tool.mypy]
73
+ files = ["."]
74
+ # strictness:
75
+ check_untyped_defs = true
76
+ # messages configuration:
77
+ show_error_context = true
78
+ show_column_numbers = true
79
+ show_error_codes = true
80
+ pretty = true
81
+ show_traceback = true
82
+
83
+ [[tool.mypy.overrides]]
84
+ module = [
85
+ "aiosonic.*",
86
+ "apscheduler.*",
87
+ "async_cron.*",
88
+ "coloredlogs.*",
89
+ "decouple",
90
+ "discord.*",
91
+ "discord_argparse",
92
+ "dramatiq.*",
93
+ "gunicorn.*",
94
+ "redis_lock",
95
+ "sentry_dramatiq",
96
+ "uvloop",
97
+ ]
98
+ ignore_missing_imports = true
@@ -19,7 +19,11 @@ if TYPE_CHECKING:
19
19
 
20
20
  HERE = Path(__file__).parent
21
21
  DEFAULT_ENCODING = "utf-8"
22
- MAIN_CONFIG = toml.loads((HERE / "common_pyproject.toml").read_text(encoding=DEFAULT_ENCODING))
22
+
23
+ RUFF_CONFIG = toml.loads((HERE / "ruff.toml").read_text(encoding=DEFAULT_ENCODING))
24
+ COMMON_CONFIG = toml.loads((HERE / "common_pyproject.toml").read_text(encoding=DEFAULT_ENCODING))
25
+ MAIN_CONFIG = deep_merge(COMMON_CONFIG, {"tool": {"ruff": RUFF_CONFIG}})
26
+
23
27
  DEFAULT_UV_RUN_ARGS = ("--group=dev", "--isolated")
24
28
  ENVWRAP_RERUN_FLAG_KEY = "HYD_ENVWRAP_RERUN_DONE"
25
29
 
@@ -84,6 +88,17 @@ class LocalConfigManager:
84
88
  return ["uv", "run", *self.command_run_uv_args, "--"]
85
89
  return []
86
90
 
91
+ def is_tool_enabled(self, tool_name: str, *, default: bool = True) -> bool:
92
+ cfg_path = ("tool", "hydev", f"enable_{tool_name}")
93
+ try:
94
+ cfg = getitem_path(self.local_config, cfg_path)
95
+ except KeyError:
96
+ return default
97
+ else:
98
+ if not isinstance(cfg, bool):
99
+ raise ValueError(f"Expected boolean at {cfg_path}, got {type(cfg)}")
100
+ return cfg
101
+
87
102
 
88
103
  DEFAULT_LOCAL_CONFIG_MGR = LocalConfigManager()
89
104
 
@@ -141,6 +156,7 @@ def extend_ignore_paths(config, paths: list[str]):
141
156
 
142
157
 
143
158
  class CLIToolBase:
159
+ TOOL_NAME: ClassVar[str]
144
160
  local_config_mgr: ClassVar[LocalConfigManager] = DEFAULT_LOCAL_CONFIG_MGR
145
161
 
146
162
  def run(self) -> None:
@@ -154,6 +170,8 @@ class CLIToolBase:
154
170
  class CommonEnvWrapTool(CLIToolBase):
155
171
  """Ensures the tool is running in the current uv/poetry environment"""
156
172
 
173
+ TOOL_NAME: ClassVar[str]
174
+
157
175
  auto_wrap_rerun: ClassVar[bool] = True
158
176
 
159
177
  @staticmethod
@@ -198,7 +216,8 @@ class CommonEnvWrapTool(CLIToolBase):
198
216
 
199
217
 
200
218
  class CommonCLITool(CommonEnvWrapTool):
201
- tool_name: str
219
+ TOOL_NAME: ClassVar[str]
220
+
202
221
  should_add_default_path: bool = False
203
222
  ignored_args: frozenset[str] = frozenset(["--check"])
204
223
  concatenate_disable_suffix: ClassVar[str] = "__replace"
@@ -292,7 +311,7 @@ class CommonCLITool(CommonEnvWrapTool):
292
311
  *run_prefix,
293
312
  "python",
294
313
  "-m",
295
- self.tool_name,
314
+ self.TOOL_NAME,
296
315
  *self.tool_extra_args(),
297
316
  *extra_args,
298
317
  ]
@@ -336,7 +355,7 @@ class ConfiguredCLITool(CommonCLITool):
336
355
  class RuffBase(ConfiguredCLITool):
337
356
  ruff_command: str
338
357
 
339
- tool_name: str = "ruff"
358
+ TOOL_NAME: ClassVar[str] = "ruff"
340
359
  config_flag: str = "--config"
341
360
 
342
361
  def tool_extra_args(self) -> Sequence[str]:
@@ -366,7 +385,7 @@ class Autoflake(CommonCLITool):
366
385
  build the extra args.
367
386
  """
368
387
 
369
- tool_name: str = "autoflake"
388
+ TOOL_NAME: ClassVar[str] = "autoflake"
370
389
  should_add_default_path: bool = True
371
390
  ignored_args: frozenset[str] = ConfiguredCLITool.ignored_args - {"--check"}
372
391
 
@@ -381,21 +400,21 @@ class Autoflake(CommonCLITool):
381
400
 
382
401
 
383
402
  class ISort(ConfiguredCLITool):
384
- tool_name: str = "isort"
403
+ TOOL_NAME: ClassVar[str] = "isort"
385
404
  config_flag: str = "--settings"
386
405
  should_add_default_path: bool = True
387
406
  ignored_args: frozenset[str] = ConfiguredCLITool.ignored_args - {"--check"}
388
407
 
389
408
 
390
409
  class Black(ConfiguredCLITool):
391
- tool_name: str = "black"
410
+ TOOL_NAME: ClassVar[str] = "black"
392
411
  config_flag: str = "--config"
393
412
  should_add_default_path: bool = True
394
413
  ignored_args: frozenset[str] = ConfiguredCLITool.ignored_args - {"--check"}
395
414
 
396
415
 
397
416
  class Flake8(ConfiguredCLITool):
398
- tool_name: str = "flake8"
417
+ TOOL_NAME: ClassVar[str] = "flake8"
399
418
  config_flag: str = "--config"
400
419
  config_ext: str = "cfg" # as in `setup.cfg`
401
420
 
@@ -404,12 +423,12 @@ class Flake8(ConfiguredCLITool):
404
423
 
405
424
 
406
425
  class Mypy(ConfiguredCLITool):
407
- tool_name: str = "mypy"
426
+ TOOL_NAME: ClassVar[str] = "mypy"
408
427
  config_flag: str = "--config-file"
409
428
 
410
429
 
411
430
  class Pytest(ConfiguredCLITool):
412
- tool_name: str = "pytest"
431
+ TOOL_NAME: ClassVar[str] = "pytest"
413
432
  config_flag: str = "-c"
414
433
 
415
434
  def tool_extra_args(self) -> Sequence[str]:
@@ -419,9 +438,13 @@ class Pytest(ConfiguredCLITool):
419
438
  class CLIToolWrapper(CommonEnvWrapTool):
420
439
  wrapped: tuple[type[CLIToolBase], ...]
421
440
 
441
+ def is_enabled(self, tool_name: str) -> bool:
442
+ return self.local_config_mgr.is_tool_enabled(tool_name)
443
+
422
444
  def run(self) -> None:
423
445
  for tool in self.wrapped:
424
- tool.run_cli()
446
+ if self.is_enabled(tool.TOOL_NAME):
447
+ tool.run_cli()
425
448
 
426
449
 
427
450
  class Format(CLIToolWrapper):
@@ -1,25 +1,11 @@
1
- [tool.hydev]
2
- ignore_paths = [
3
- "*.egg-info",
4
- ".env",
5
- ".git",
6
- ".tox",
7
- ".venv",
8
- ".cache",
9
- # # Enabling these would require support for root-folder filtering in all tool configs.
10
- # "/build",
11
- # "/dist",
12
- ]
13
-
14
- [tool.ruff]
15
1
  # See also: “Known Deviations from Black”: https://docs.astral.sh/ruff/formatter/black/
16
2
  line-length = 120
17
3
  extend-include = ["*.ipynb"]
18
4
 
19
- [tool.ruff.format]
5
+ [format]
20
6
  docstring-code-format = true
21
7
 
22
- [tool.ruff.lint]
8
+ [lint]
23
9
  # https://docs.astral.sh/ruff/rules/
24
10
  select = [
25
11
  "AIR", # apache-airflow checks
@@ -148,95 +134,9 @@ external = [
148
134
  "T201",
149
135
  ]
150
136
 
151
- [tool.ruff.lint.flake8-quotes]
137
+ [lint.flake8-quotes]
152
138
  docstring-quotes = "double"
153
139
 
154
- [tool.ruff.lint.flake8-pytest-style]
140
+ [lint.flake8-pytest-style]
155
141
  fixture-parentheses = false
156
142
  mark-parentheses = false
157
-
158
- [tool.isort]
159
- profile = "black"
160
- default_section = "THIRDPARTY"
161
- include_trailing_comma = true
162
- use_parentheses = true
163
- multi_line_output = 3
164
-
165
- [tool.black]
166
- line-length = 120
167
-
168
- [tool.flake8]
169
- max-line-length = 120
170
- show-source = true
171
- statistics = false
172
- enable-extensions = ["G", "FS003"]
173
- ignore = [
174
- # If `flake8-future-import` is present, only require `from __future__ import annotations`.
175
- "FI10", "FI11", "FI12", "FI13", "FI14", "FI15", "FI16", "FI17", "FI58",
176
- # Prefer “line break before binary operator” over W504 “line break after binary operator”
177
- "W503",
178
- # Conflicts with `ruff`
179
- "E203", # “E203 whitespace before ':'” on e.g. `lst[idx : idx + size]`
180
- # Leave the line length checking to ruff
181
- "E501", # "line too long"
182
- # Disable "E704 multiple statements on one line (def)" because of `black`
183
- # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html
184
- "E704",
185
- ]
186
- per-file-ignores = [
187
- "__init__.py:F401,F403", # “imported but unused”, “'import *' used”
188
- ]
189
-
190
- [tool.pytest.ini_options]
191
- timeout = 5
192
- xfail_strict = true
193
- addopts = [
194
- "--blockage",
195
- "--blockage-http-whitelist=localhost,127.0.0.1",
196
- "--strict-markers",
197
- "--strict-config",
198
- "--dup-fixtures",
199
- # Output:
200
- "--tb=short",
201
- # Parallelism:
202
- # "-n auto",
203
- # "--boxed",
204
- # Coverage:,
205
- "--cov-branch",
206
- "--cov-report=term-missing:skip-covered",
207
- "--cov-report=html",
208
- "--cov=src",
209
- "--cov=tests",
210
- ]
211
- env = [
212
- "RUN_ENV=tests",
213
- ]
214
-
215
-
216
- [tool.mypy]
217
- files = ["."]
218
- # strictness:
219
- check_untyped_defs = true
220
- # messages configuration:
221
- show_error_context = true
222
- show_column_numbers = true
223
- show_error_codes = true
224
- pretty = true
225
- show_traceback = true
226
-
227
- [[tool.mypy.overrides]]
228
- module = [
229
- "aiosonic.*",
230
- "apscheduler.*",
231
- "async_cron.*",
232
- "coloredlogs.*",
233
- "decouple",
234
- "discord.*",
235
- "discord_argparse",
236
- "dramatiq.*",
237
- "gunicorn.*",
238
- "redis_lock",
239
- "sentry_dramatiq",
240
- "uvloop",
241
- ]
242
- ignore_missing_imports = true
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes