Skip to content

Commit f97a82f

Browse files
Merge pull request #4 from MPCodeWriter21/V3
V3 Update
2 parents bc39c3e + 2f7d5b2 commit f97a82f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4637
-1337
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ A clear and concise description of what you expected to happen.
2020
If applicable, add screenshots to help explain your problem.
2121

2222
**Desktop (please complete the following information):**
23-
- OS: [e.g. Windows]
24-
- Version [e.g. 2.0.0]
23+
24+
- OS: [e.g. Windows]
25+
- Version [e.g. 2.0.0]
2526

2627
**Smartphone (please complete the following information):**
27-
- Device: [e.g. Samsung Galaxy A52s]
28-
- OS: [e.g. Android 10]
29-
- Version [e.g. 2.0.0]
28+
29+
- Device: [e.g. Samsung Galaxy A52s]
30+
- OS: [e.g. Android 10]
31+
- Version [e.g. 2.0.0]
3032

3133
**Additional context**
3234
Add any other context about the problem here.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ ipython_config.py
9191
# install all needed dependencies.
9292
#Pipfile.lock
9393

94+
# UV
95+
uv.lock
96+
97+
9498
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
9599
__pypackages__/
96100

.pre-commit-config.yaml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
1-
default_language_version:
2-
python: python3.8
31
repos:
42
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v3.2.0
3+
rev: v6.0.0
64
hooks:
7-
- id: trailing-whitespace
8-
- id: check-yaml
9-
- id: check-added-large-files
10-
- id: double-quote-string-fixer
11-
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-case-conflict
10+
- id: check-merge-conflict
11+
- id: debug-statements
12+
- repo: https://github.com/google/yapf
13+
rev: v0.43.0
14+
hooks:
15+
- id: yapf
16+
args: ['-i', '-m']
1217
- repo: https://github.com/pycqa/isort
13-
rev: 5.13.2
18+
rev: 7.0.0
1419
hooks:
1520
- id: isort
16-
name: isort
17-
18-
- repo: https://github.com/PyCQA/docformatter
19-
rev: v1.7.5
21+
# - repo: https://github.com/astral-sh/ruff-pre-commit
22+
# rev: v0.14.10
23+
# hooks:
24+
# - id: ruff
25+
- repo: https://github.com/DavidAnson/markdownlint-cli2
26+
rev: v0.20.0
2027
hooks:
21-
- id: docformatter
22-
additional_dependencies: [tomli]
23-
args: [./pyproject.toml]
28+
- id: markdownlint-cli2
29+
args: [--fix]
30+
- repo: https://github.com/netromdk/vermin
31+
rev: v1.8.0
32+
hooks:
33+
- id: vermin
34+
args: [
35+
'--lint', '--no-make-paths-absolute', '--eval-annotations', '--backport',
36+
'argparse', '--backport', 'typing', '--backport', 'asyncio', '--backport',
37+
'dataclasses', '--backport', 'enum', '-t=3.9-', '--violations'
38+
]
39+
40+
exclude: |
41+
(?x)^(
42+
src/log21/_argparse.py|
43+
examples/.*.py
44+
)$

CHANGELOG.md

Lines changed: 124 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,76 @@ Help this project by [Donation](DONATE.md)
66
Changes
77
-------
88

9+
### v3.0.0
10+
11+
This release introduces a cleaned-up internal structure, stricter naming conventions,
12+
and several quality-of-life improvements. While most users will not notice behavioral
13+
changes, **v3 contains breaking changes for code that relies on internal imports or
14+
specific exception names**.
15+
16+
#### Breaking Changes
17+
18+
+ **Internal module renaming and normalization**
19+
+ All internal modules were renamed to lowercase and, in some cases, split or
20+
reorganized.
21+
+ Imports such as `log21.Colors`, `log21.Logger`, `log21.ProgressBar`, etc. are no
22+
longer valid.
23+
+ Users importing from internal modules must update their imports to the new module
24+
names.
25+
+ Public imports from `log21` remain supported.
26+
27+
+ **Argumentify exception renames**
28+
+ Several exceptions were renamed to follow a consistent `*Error` naming convention:
29+
+ `TooFewArguments``TooFewArgumentsError`
30+
+ `RequiredArgument``RequiredArgumentError`
31+
+ `IncompatibleArguments``IncompatibleArgumentsError`
32+
+ Code that explicitly raises or catches these exceptions must be updated.
33+
34+
#### V3 Changes
35+
36+
+ **Crash reporter behavior improvement**
37+
+ Prevented the default file crash reporter from creating `.crash_report` files when it
38+
is not actually used.
39+
+ Implemented using an internal `FakeModule` helper.
40+
41+
+ **Argparse compatibility update**
42+
+ Bundled and used the Python 3.13 `argparse` implementation to ensure consistent
43+
behavior across supported Python versions.
44+
45+
+ **Progress bar module rename**
46+
+ Renamed the internal progress bar module to `progress_bar` for consistency with the
47+
new naming scheme.
48+
+ This will not break the usages of `log21.progress_bar(...)` since the call
49+
functionality was added to the module using the `FakeModule` helper.
50+
51+
+ **Examples added and updated**
52+
+ Added new example code files.
53+
+ Updated existing examples to match the v3 API and conventions.
54+
55+
#### Fixes
56+
57+
+ Resolved various linting and static-analysis issues across the codebase.
58+
+ Addressed minor compatibility issues uncovered by running linters and pre-commit hooks.
59+
+ Resolved errors occurring in environments with newer versions of argparse.
60+
61+
#### Internal and Maintenance Changes
62+
63+
+ Migrated the build system configuration to `uv`.
64+
+ Updated Python version classifiers and set the supported Python version to 3.9+.
65+
+ Added `vermin` to the pre-commit configuration.
66+
+ Updated `.gitignore`, license metadata, and tool configurations.
67+
+ Silenced and resolved a large number of linter warnings.
68+
+ General internal refactoring with no intended user-visible behavioral changes.
69+
70+
#### Notes
71+
72+
+ There are **no intentional behavioral changes** in logging output, argument parsing
73+
logic, or UI components.
74+
+ Most projects will require **minimal or no changes** unless they depend on internal
75+
modules or renamed exceptions.
76+
+ See [MIGRATION-V2-V3.md](https://github.com/MPCodeWriter21/log21/blob/master/MIGRATION-V2-V3.md)
77+
for detailed upgrade instructions.
78+
979
### 2.10.2
1080

1181
+ Update README.md and CHANGELOG.md.
@@ -93,7 +163,7 @@ Change in README.md.
93163

94164
### 2.6.1
95165

96-
+ Added `encoding` to `log21.CrashReporter.FileReporter`.
166+
+ Added `encoding` to `log21.crash_reporter.FileReporter`.
97167
+ Added configs for `pylint`, `yapf` and `isort` to `pyproject.toml`.
98168
+ Added optional `dev` dependencies to `pyproject.toml`.
99169
+ Improved overall code quality.
@@ -120,10 +190,12 @@ print(GREEN + 'This' + WHITE + ' is' + RED + ' Red')
120190
### 2.5.3
121191

122192
Moved some dictionaries to `__init__` methods.
123-
`colors` in `Argparse.ColorizingHelpFormatter` class.
124-
`_level_name` in `Formatters._Formatter` class and `level_colors` in `Formatters.ColorizingFormatter` class.
125-
`sign_colors` in `PPrint.PrettyPrinter` class.
126-
`colors` in `TreePrint.TreePrint.Node` class.
193+
194+
+ `colors` in `Argparse.ColorizingHelpFormatter` class.
195+
+ `_level_name` in `Formatters._Formatter` class and `level_colors` in
196+
`Formatters.ColorizingFormatter` class.
197+
+ `sign_colors` in `PPrint.PrettyPrinter` class.
198+
+ `colors` in `TreePrint.TreePrint.Node` class.
127199

128200
### 2.5.2
129201

@@ -135,17 +207,17 @@ Switched from `setup.py` build system to `pyproject.toml`
135207

136208
### 2.5.0
137209

138-
Added `level_colors` argument to `log21.get_logger` function with will be passed to the formatter and allows
139-
user to set custom level colors while making a new logger.
140-
Also changed most `Dict` type hints to be `Mapping` and `list` to `Sequence` to make the functions more general
141-
and less strict.
210+
Added `level_colors` argument to `log21.get_logger` function with will be passed to the
211+
formatter and allows user to set custom level colors while making a new logger.
212+
Also changed most `Dict` type hints to be `Mapping` and `list` to `Sequence` to make the
213+
functions more general and less strict.
142214

143215
### 2.4.7
144216

145-
Added `extra_values` argument to `CrashReporter.Formatter` which will let you pass extra static or dynamic values to the
146-
report formatter.
147-
They can be used in the format string. For dynamic values you can pass a function that takes no
148-
arguments as the value.
217+
Added `extra_values` argument to `crash_reporter.Formatter` which will let you pass extra
218+
static or dynamic values to the report formatter.
219+
They can be used in the format string. For dynamic values you can pass a function that
220+
takes no arguments as the value.
149221

150222
### 2.4.6
151223

@@ -155,10 +227,10 @@ Shortened the usage syntax for the CrashReporters:
155227
import log21
156228

157229
# Define a ConsoleReporter object
158-
console_reporter = log21.CrashReporter.ConsoleReporter()
230+
console_reporter = log21.crash_reporter.ConsoleReporter()
159231

160232

161-
# This works with other `log21.CrashReporter.Reporter` subclasses as well.
233+
# This works with other `log21.crash_reporter.reporter` subclasses as well.
162234

163235
# Old syntax (still supported)
164236
@console_reporter.reporter
@@ -214,7 +286,8 @@ Added `catch` and `ignore` methods to `log21.CrashReporter.Reporter`.
214286

215287
### 2.3.7
216288

217-
Added `exceptions_to_catch` and `exceptions_to_ignore` arguments to `log21.CrashReporter.Reporter` class.
289+
Added `exceptions_to_catch` and `exceptions_to_ignore` arguments to
290+
`log21.CrashReporter.Reporter` class.
218291

219292
### 2.3.6
220293

@@ -226,35 +299,39 @@ Minor improvements.
226299

227300
### 2.3.4
228301

229-
Added a new method to `log21.Logger` class: `log21.Logger.clear_line`. This method clears the current line in the
230-
console and moves the cursor to the beginning of the line.
302+
Added a new method to `log21.Logger` class: `log21.Logger.clear_line`. This method
303+
clears the current line in the console and moves the cursor to the beginning of the line.
231304

232305
### 2.3.3
233306

234-
Fixed a bug that would cause an error creating a progress bar with no value set for width in systems without support for
235-
os.get_terminal_size().
307+
Fixed a bug that would cause an error creating a progress bar with no value set for
308+
width in systems without support for os.get_terminal_size().
236309

237310
### 2.3.2
238311

239-
Added `additional_variables` argument to `log21.ProgressBar` class. You can use it in order to add additional variables
240-
to the progress bar:
312+
Added `additional_variables` argument to `log21.ProgressBar` class. You can use it in
313+
order to add additional variables to the progress bar:
241314

242315
```python3
243316
import log21, time
244317

245-
progress_bar = log21.ProgressBar(format_='Iteration: {i} {prefix}{bar}{suffix} {percentage}%', style='{',
246-
additional_variables={"i": 0})
318+
progress_bar = log21.ProgressBar(
319+
format_='Iteration: {i} {prefix}{bar}{suffix} {percentage}%',
320+
style='{',
321+
additional_variables={"i": 0}
322+
)
247323

248324
for i in range(100):
249325
progress_bar(i + 1, 100, i=i)
250326
time.sleep(0.1)
251-
# Iteration: 99 |██████████████████████████████████████████████████████████████████████████████| 100%
327+
# Iteration: 99 |████████████████████████████████████████████████████████████████| 100%
252328
```
253329

254330
### 2.3.1
255331

256-
Added `formatter` argument to `StreamHandler` and `FileHandler`. You can use it to set the formatter of the handler when
257-
you create it. Added `handlers` argument to `Logger`. You can use it to add handlers to the logger when you create it.
332+
Added `formatter` argument to `StreamHandler` and `FileHandler`. You can use it to set
333+
the formatter of the handler when you create it. Added `handlers` argument to `Logger`.
334+
You can use it to add handlers to the logger when you create it.
258335

259336
### 2.3.0
260337

@@ -267,13 +344,15 @@ Let's see an example:
267344
```python
268345
# We import the ProgressBar class from log21
269346
from log21 import ProgressBar
270-
# psutil is a module that can be used to get the current memory usage or cpu usage of your system
347+
# psutil is a module that can be used to get the current memory usage or cpu usage of
348+
# your system
271349
# If you want to try this example, you need to install psutil: pip install psutil
272350
import psutil
273351
# We use the time module to make a delay between the progressbar updates
274352
import time
275353

276-
cpu_bar = ProgressBar(format_='CPU Usage: {prefix}{bar}{suffix} {percentage}%', style='{', new_line_when_complete=False)
354+
cpu_bar = ProgressBar(format_='CPU Usage: {prefix}{bar}{suffix} {percentage}%',
355+
style='{', new_line_when_complete=False)
277356

278357
while True:
279358
cpu_bar.update(psutil.cpu_percent(), 100)
@@ -284,9 +363,9 @@ while True:
284363

285364
Added CrashReporter!
286365

287-
You can use Reporter classes to monitor your program and send crash reports to the developer. It can help you fix the
288-
bugs and improve your program before your users get upset about it. See some examples in
289-
the [log21/CrashReporter/Reporters.py](https://github.com/MPCodeWriter21/log21/blob/master/log21/CrashReporter/Reporters.py)
366+
You can use Reporter classes to monitor your program and send crash reports to the
367+
developer. It can help you fix the bugs and improve your program before your users get
368+
upset about it. See some examples in the [log21/crash\_reporter/reporters.py](https://github.com/MPCodeWriter21/log21/blob/master/log21/CrashReporter/Reporters.py)
290369
file.
291370

292371
### 2.1.8
@@ -325,7 +404,8 @@ Added LoggingWindow!
325404

326405
Added `ProgressBar` class!
327406

328-
You can directly print a progress bar to the console using `print_progress` method of `log21.Logger` class.
407+
You can directly print a progress bar to the console using `print_progress` method of
408+
`log21.Logger` class.
329409

330410
OR
331411

@@ -341,7 +421,8 @@ Minor changes.
341421

342422
### 1.5.8
343423

344-
Added `log21.log`, `log21.debug`, `log21.info`, `log21.warning`, `log21.error` and some other functions.
424+
Added `log21.log`, `log21.debug`, `log21.info`, `log21.warning`, `log21.error` and some
425+
other functions.
345426

346427
### 1.5.7
347428

@@ -354,7 +435,8 @@ Added `log21.pprint()` function. It is similar to `pprint.pprint()` function.
354435
### 1.5.5
355436

356437
Added `level_names` argument to Formatter classes.
357-
`level_names` can be used to change the name of logging level that appears while logging messages.
438+
`level_names` can be used to change the name of logging level that appears while logging
439+
messages.
358440

359441
### 1.5.3-4
360442

@@ -374,11 +456,13 @@ More description added.
374456

375457
### 1.4.12
376458

377-
Setting custom formatting style and custom date-time formatting added to `log21.get_logger` function.
459+
Setting custom formatting style and custom date-time formatting added to
460+
`log21.get_logger` function.
378461

379462
### 1.4.11
380463

381-
`Logger.write` edited. It's same as `Logger.warning` but its default `end` argument value is an empty string.
464+
`Logger.write` edited. It's same as `Logger.warning` but its default `end` argument
465+
value is an empty string.
382466

383467
### 1.4.10
384468

@@ -388,7 +472,7 @@ Setting custom formatting style and custom date-time formatting added to `log21.
388472

389473
Bug fixed:
390474

391-
```
475+
```python
392476
>>> log21.get_logger()
393477
Traceback (most recent call last):
394478
File "<stdin>", line 1, in <module>
@@ -405,7 +489,8 @@ TypeError: A logger name must be a string
405489

406490
`Logger.print` added.
407491

408-
You can use `Logger.print` to print a message using the current level of the logger class.
492+
You can use `Logger.print` to print a message using the current level of the logger
493+
class.
409494

410495
*It gets printed with any level.*
411496

0 commit comments

Comments
 (0)