hunterMakesPy 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl

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.
hunterMakesPy/__init__.py CHANGED
@@ -8,26 +8,15 @@ This package provides:
8
8
 
9
9
  """
10
10
 
11
- # isort: split
12
11
  from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute, Ordinals as Ordinals
13
12
 
14
- # isort: split
15
13
  from hunterMakesPy.coping import PackageSettings as PackageSettings, raiseIfNone as raiseIfNone
16
14
 
17
- # isort: split
18
- from hunterMakesPy.parseParameters import (
19
- defineConcurrencyLimit as defineConcurrencyLimit, intInnit as intInnit, oopsieKwargsie as oopsieKwargsie)
15
+ from hunterMakesPy.parseParameters import defineConcurrencyLimit, intInnit, oopsieKwargsie
20
16
 
21
- # isort: split
22
17
  from hunterMakesPy.filesystemToolkit import (
23
- importLogicalPath2Identifier as importLogicalPath2Identifier,
24
- importPathFilename2Identifier as importPathFilename2Identifier, makeDirsSafely as makeDirsSafely,
25
- writePython as writePython, writeStringToHere as writeStringToHere)
18
+ importLogicalPath2Identifier, importPathFilename2Identifier, makeDirsSafely, writePython, writeStringToHere)
26
19
 
27
- # isort: split
28
- from hunterMakesPy.dataStructures import (
29
- autoDecodingRLE as autoDecodingRLE, stringItUp as stringItUp,
30
- updateExtendPolishDictionaryLists as updateExtendPolishDictionaryLists)
20
+ from hunterMakesPy.dataStructures import autoDecodingRLE, stringItUp, updateExtendPolishDictionaryLists
31
21
 
32
- # isort: split
33
22
  from hunterMakesPy._theSSOT import settingsPackage # pyright: ignore[reportUnusedImport]
@@ -267,7 +267,7 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[str, list[小于
267
267
  for keyName, keyValue in dictionaryListTarget.items():
268
268
  try:
269
269
  ImaStr = str(keyName)
270
- ImaList = list(keyValue)
270
+ ImaList: list[小于] = list(keyValue)
271
271
  ePluribusUnum.setdefault(ImaStr, []).extend(ImaList)
272
272
  except TypeError:
273
273
  if killErroneousDataTypes:
@@ -118,7 +118,6 @@ settings_isortDEFAULT: dict[str, bool | int | str | list[str]] = {
118
118
  "lines_between_types": 0,
119
119
  "multi_line_output": 4,
120
120
  "no_sections": True,
121
- "skip": ["__init__.py"], # TODO think
122
121
  "use_parentheses": True,
123
122
  }
124
123
 
@@ -148,21 +148,18 @@ def defineConcurrencyLimit(*, limit: bool | float | int | None, cpuTotal: int =
148
148
  limit = limitFromString
149
149
  if isinstance(limit, float) and abs(limit) >= 1:
150
150
  limit = round(limit)
151
- match limit:
152
- case None | False | 0:
153
- pass
154
- case True:
155
- concurrencyLimit = 1
156
- case _ if limit >= 1:
157
- concurrencyLimit = int(limit)
158
- case _ if 0 < limit < 1:
159
- concurrencyLimit = round(limit * cpuTotal)
160
- case _ if -1 < limit < 0:
161
- concurrencyLimit = cpuTotal - abs(round(limit * cpuTotal))
162
- case _ if limit <= -1:
163
- concurrencyLimit = cpuTotal - abs(int(limit))
164
- case _:
165
- pass
151
+ if limit is None or limit is False or limit == 0:
152
+ pass
153
+ elif limit is True:
154
+ concurrencyLimit = 1
155
+ elif limit >= 1:
156
+ concurrencyLimit = int(limit)
157
+ elif 0 < limit < 1:
158
+ concurrencyLimit = round(limit * cpuTotal)
159
+ elif -1 < limit < 0:
160
+ concurrencyLimit = cpuTotal - abs(round(limit * cpuTotal))
161
+ elif limit <= -1:
162
+ concurrencyLimit = cpuTotal - abs(int(limit))
166
163
 
167
164
  return max(int(concurrencyLimit), 1)
168
165
 
@@ -208,7 +205,7 @@ def intInnit(listInt_Allegedly: Iterable[Any], parameterName: str | None = None,
208
205
  parameterType = parameterType or list
209
206
 
210
207
  if not listInt_Allegedly:
211
- message = f"I did not receive a value for {parameterName}, but it is required."
208
+ message: str = f"I did not receive a value for {parameterName}, but it is required."
212
209
  raise ValueError(message)
213
210
 
214
211
  # Be nice, and assume the input container is valid and every element is valid.
@@ -319,11 +316,3 @@ def oopsieKwargsie(huh: Any) -> bool | None | str:
319
316
  if formatted == str(None):
320
317
  return None
321
318
  return huh
322
-
323
- if __name__ == '__main__':
324
- # Frankly, I cannot remember the precise reason I put this in some modules. It solved a concurrency problem I was having at the time,
325
- # but it felt like a hack at the time and it feels even more like a hack now. I suspect I will eventually learn enough so that I can
326
- # come full circle: know why I added it, know how I already fixed the real issue, and know that I can safely remove this. # noqa: ERA001
327
- multiprocessing.set_start_method('spawn')
328
-
329
- # Well, actually, I don't want to be programming for so long that I learn that much. I want to heal and do things in my areas of competency.
@@ -6,5 +6,4 @@ Note: These test functions are now in `hunterMakesPy.tests` with all other tests
6
6
  """
7
7
 
8
8
  from hunterMakesPy.tests.test_parseParameters import (
9
- PytestFor_defineConcurrencyLimit as PytestFor_defineConcurrencyLimit, PytestFor_intInnit as PytestFor_intInnit,
10
- PytestFor_oopsieKwargsie as PytestFor_oopsieKwargsie)
9
+ PytestFor_defineConcurrencyLimit, PytestFor_intInnit, PytestFor_oopsieKwargsie)
@@ -1,3 +1,11 @@
1
+ """Configuration and fixtures for pytest.
2
+
3
+ (AI generated docstring)
4
+
5
+ This module provides shared fixtures and utility functions for the test suite,
6
+ including data paths, source code samples, and standardized assertion helpers.
7
+
8
+ """
1
9
  # pyright: standard
2
10
  from collections.abc import Callable
3
11
  from typing import Any
@@ -6,11 +14,26 @@ import pathlib
6
14
  import pytest
7
15
 
8
16
  # SSOT for test data paths and filenames
9
- pathDataSamples = pathlib.Path("hunterMakesPy/tests/dataSamples")
17
+ pathDataSamples: pathlib.Path = pathlib.Path("hunterMakesPy/tests/dataSamples")
10
18
 
11
19
  # Fixture to provide a temporary directory for filesystem tests
12
20
  @pytest.fixture
13
21
  def pathTmpTesting(tmp_path: pathlib.Path) -> pathlib.Path:
22
+ """Provide a temporary directory for filesystem tests.
23
+
24
+ (AI generated docstring)
25
+
26
+ Parameters
27
+ ----------
28
+ tmp_path : pathlib.Path
29
+ The pytest built-in temporary path fixture.
30
+
31
+ Returns
32
+ -------
33
+ pathTmpTesting : pathlib.Path
34
+ The path to the temporary directory.
35
+
36
+ """
14
37
  return tmp_path
15
38
 
16
39
  # Fixture for predictable Python source code samples
@@ -44,7 +67,27 @@ def listFileContentsFibonacci() -> list[str]:
44
67
  return ['fibonacci8', 'fibonacci13', 'fibonacci21', 'fibonacci34']
45
68
 
46
69
  def uniformTestFailureMessage(expected: Any, actual: Any, functionName: str, *arguments: Any, **keywordArguments: Any) -> str:
47
- """Format assertion message for any test comparison."""
70
+ """Format assertion message for any test comparison.
71
+
72
+ Parameters
73
+ ----------
74
+ expected : Any
75
+ The expected value or outcome.
76
+ actual : Any
77
+ The actual value or outcome received.
78
+ functionName : str
79
+ The name of the function or test case being executed.
80
+ *arguments : Any
81
+ Positional arguments passed to the function having its return value checked.
82
+ **keywordArguments : Any
83
+ Keyword arguments passed to the function having its return value checked.
84
+
85
+ Returns
86
+ -------
87
+ message : str
88
+ A formatted failure message detailing the expectation vs reality.
89
+
90
+ """
48
91
  listArgumentComponents: list[str] = [str(parameter) for parameter in arguments]
49
92
  listKeywordComponents: list[str] = [f"{key}={value}" for key, value in keywordArguments.items()]
50
93
  joinedArguments: str = ', '.join(listArgumentComponents + listKeywordComponents)
@@ -54,7 +97,22 @@ def uniformTestFailureMessage(expected: Any, actual: Any, functionName: str, *ar
54
97
  f"Got: {actual}")
55
98
 
56
99
  def standardizedEqualTo(expected: Any, functionTarget: Callable[..., Any], *arguments: Any, **keywordArguments: Any) -> None:
57
- """Template for most tests to compare the actual outcome with the expected outcome, including expected errors."""
100
+ """Template for most tests to compare actual outcome with expected outcome.
101
+
102
+ Includes handling for expected errors/exceptions.
103
+
104
+ Parameters
105
+ ----------
106
+ expected : Any
107
+ The expected return value, or an Exception type if an error is expected.
108
+ functionTarget : Callable[..., Any]
109
+ The function to call and test.
110
+ *arguments : Any
111
+ Positional arguments to pass to `functionTarget`.
112
+ **keywordArguments : Any
113
+ Keyword arguments to pass to `functionTarget`.
114
+
115
+ """
58
116
  if type(expected) == type[Exception]: # noqa: E721
59
117
  messageExpected: str = expected.__name__
60
118
  else:
@@ -63,7 +121,23 @@ def standardizedEqualTo(expected: Any, functionTarget: Callable[..., Any], *argu
63
121
  try:
64
122
  messageActual = actual = functionTarget(*arguments, **keywordArguments)
65
123
  except Exception as actualError:
66
- messageActual: str = type(actualError).__name__
124
+ messageActual = type(actualError).__name__
67
125
  actual = type(actualError)
68
126
 
69
- assert actual == expected, uniformTestFailureMessage(messageExpected, messageActual, functionTarget.__name__, *arguments, **keywordArguments)
127
+ functionName: str = getattr(functionTarget, "__name__", functionTarget.__class__.__name__)
128
+ assert actual == expected, uniformTestFailureMessage(messageExpected, messageActual, functionName, *arguments, **keywordArguments)
129
+
130
+ # Why I wish I could figure out how to implement standardized* test functions.
131
+ # ruff: noqa: ERA001
132
+ # standardizedEqualTo(expected, updateExtendPolishDictionaryLists, *value_dictionaryLists, **keywordArguments)
133
+ # NOTE one line of code with `standardizedEqualTo` (above) replaced the following ten lines of code. Use `standardizedEqualTo`.
134
+ # if isinstance(expected, type) and issubclass(expected, Exception):
135
+ # with pytest.raises(expected):
136
+ # updateExtendPolishDictionaryLists(*value_dictionaryLists, **keywordArguments)
137
+ # else:
138
+ # result = updateExtendPolishDictionaryLists(*value_dictionaryLists, **keywordArguments)
139
+ # if description == "Set values": # Special handling for unordered sets
140
+ # for key in result:
141
+ # assert sorted(result[key]) == sorted(expected[key])
142
+ # else:
143
+ # assert result == expected