Skip to content

Commit 64c18c3

Browse files
committed
docstring linting & small bugfix
1 parent 416e947 commit 64c18c3

6 files changed

Lines changed: 39 additions & 39 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* All methods that should use positional-only and/or keyword-only params, now actually enforce that by using the `/` and `*` syntax in the method definitions.
2828
* Renamed the `Spinner` class from the `console` module to `Throbber`, since that name is closer to what it's actually used for.
2929
* Changed the name of the TypeAlias `DataStructure` to `DataObj` because that name is shorter and more general.
30-
* Changed both names `DataStructureTypes` and `IndexIterableTypes` to `DataObjTT` and `IndexIterableTT` respectively (`TT` *stands for types-tuple*).
30+
* Changed both names `DataStructureTypes` and `IndexIterableTypes` to `DataObjTT` and `IndexIterableTT` respectively (`TT` *stands for type-tuple*).
3131
* Made the return value of `String.single_char_repeats()` always be *`int`* and not <code>*int* | *bool*</code>.
3232

3333

@@ -498,10 +498,10 @@
498498
## 21.12.2024 `v1.5.9`
499499

500500
* Fixed bugs in method `to_ansi()` in module `xx_format_codes`:<br>
501-
1. The method always returned an empty string, because the color validation was broken, and it would identify all colors as invalid.<br>
502-
Now the validation `Color.is_valid_rgba()` and `Color.is_valid_hexa()` are fixed and now, if a color is identified as invalid, the method returns the original string instead of an empty string.
503-
2. Previously the method `to_ansi()` couldn't handle formats inside `[]` because everything inside the brackets was recognized as an invalid format.<br>
504-
Now you are able to use formats inside `[]` (*e.g.* `"[[red](Red text [b](inside) square brackets!)]"`).
501+
1. The method always returned an empty string, because the color validation was broken, and it would identify all colors as invalid.<br>
502+
Now the validation `Color.is_valid_rgba()` and `Color.is_valid_hexa()` are fixed and now, if a color is identified as invalid, the method returns the original string instead of an empty string.
503+
2. Previously the method `to_ansi()` couldn't handle formats inside `[]` because everything inside the brackets was recognized as an invalid format.<br>
504+
Now you are able to use formats inside `[]` (*e.g.* `"[[red](Red text [b](inside) square brackets!)]"`).
505505
* Introduced a new test for the `xx_format_codes` module.
506506
* Fixed a small bug in the help client-command:<br>
507507
Added back the default text color.
@@ -865,8 +865,8 @@
865865
## 15.10.2024 `v1.0.1``v1.0.2``v1.0.3``v1.0.4``v1.0.5`
866866

867867
* Fixed `f-string` issues for Python 3.10:
868-
1. Not making use of same quotes inside f-strings any more.
869-
2. No backslash escaping in f-strings.
868+
1. Not making use of same quotes inside f-strings any more.
869+
2. No backslash escaping in f-strings.
870870

871871

872872
<span id="release" /><span id="v1-0-0" />

src/xulbux/console.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,24 @@ def get_args(cls, arg_parse_configs: ArgParseConfigs, /, *, flag_value_sep: str
271271
- `flag_value_sep` - the character/s used to separate flags from their values\n
272272
-------------------------------------------------------------------------------------------------
273273
The `arg_parse_configs` dictionary can have the following structures for each item:
274-
1. Simple set of flags (when no default value is needed):
275-
```python
274+
1. Simple set of flags (when no default value is needed):
275+
```python
276276
"alias_name": {"-f", "--flag"}
277-
```
278-
2. Dictionary with the`"flags"` set, plus a specified `"default"` value:
279-
```python
277+
```
278+
2. Dictionary with the`"flags"` set, plus a specified `"default"` value:
279+
```python
280280
"alias_name": {
281281
"flags": {"-f", "--flag"},
282282
"default": "some_value",
283283
}
284-
```
285-
3. Positional value collection using the literals `"before"` or `"after"`:
286-
```python
284+
```
285+
3. Positional value collection using the literals `"before"` or `"after"`:
286+
```python
287287
# COLLECT ALL NON-FLAGGED VALUES THAT APPEAR BEFORE THE FIRST FLAG
288288
"alias_name": "before"
289289
# COLLECT ALL NON-FLAGGED VALUES THAT APPEAR AFTER THE LAST FLAG'S VALUE
290290
"alias_name": "after"
291-
```
291+
```
292292
#### Example usage:
293293
If you call the `get_args()` method in your script like this:
294294
```python
@@ -699,15 +699,15 @@ def log_box_bordered(
699699
- `"strong" = ('┏', '━', '┓', '┃', '┛', '━', '┗', '┃', '┣', '━', '┫')`
700700
- `"double" = ('╔', '═', '╗', '║', '╝', '═', '╚', '║', '╠', '═', '╣')`\n
701701
The order of the characters is always:
702-
1. top-left corner
703-
2. top border
704-
3. top-right corner
705-
4. right border
706-
5. bottom-right corner
707-
6. bottom border
708-
7. bottom-left corner
709-
8. left border
710-
9. left horizontal rule connector
702+
1. top-left corner
703+
2. top border
704+
3. top-right corner
705+
4. right border
706+
5. bottom-right corner
707+
6. bottom border
708+
7. bottom-left corner
709+
8. left border
710+
9. left horizontal rule connector
711711
10. horizontal rule
712712
11. right horizontal rule connector"""
713713
if w_padding < 0:

src/xulbux/format_codes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@
133133
------------------------------------------------------------------------------------------------------------------------------------
134134
#### Additional Formatting Codes when a `default_color` is set
135135
136-
1. `[*]` resets everything, just like `[_]`, but the text color will remain in `default_color`
137-
(if no `default_color` is set, it resets everything, exactly like `[_]`)
138-
2. `[default]` will just color the text in `default_color`
139-
(if no `default_color` is set, it's treated as an invalid formatting code)
140-
3. `[background:default]` `[BG:default]` will color the background in `default_color`
141-
(if no `default_color` is set, both are treated as invalid formatting codes)\n
136+
1. `[*]` resets everything, just like `[_]`, but the text color will remain in `default_color`
137+
(if no `default_color` is set, it resets everything, exactly like `[_]`)
138+
2. `[default]` will just color the text in `default_color`
139+
(if no `default_color` is set, it's treated as an invalid formatting code)
140+
3. `[background:default]` `[BG:default]` will color the background in `default_color`
141+
(if no `default_color` is set, both are treated as invalid formatting codes)\n
142142
143143
Unlike the standard console colors, the default color can be changed by using the following modifiers:
144144

src/xulbux/regex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def all_except(cls, disallowed_pattern: str, /, ignore_pattern: str = "", *, is_
104104
@classmethod
105105
def func_call(cls, func_name: Optional[str] = None, /) -> str:
106106
"""Match a function call, and get back two groups:
107-
1. function name
108-
2. the function's arguments\n
107+
1. The function name
108+
2. The function's arguments (content inside the parentheses)\n
109109
If no `func_name` is given, it will match any function call.\n
110110
---------------------------------------------------------------------------------
111111
Attention: Requires non-standard library `regex`, not standard library `re`!"""

src/xulbux/string.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def is_empty(cls, string: Optional[str], /, *, spaces_are_empty: bool = False) -
7070
@classmethod
7171
def single_char_repeats(cls, string: str, char: str, /) -> int:
7272
"""- If the string consists of only the same `char`, it returns the number of times it is present.
73-
- If the string doesn't consist of only the same character, it returns `0`.\n
73+
- If the string is empty or doesn't consist of only the same character, it returns `0`.\n
7474
---------------------------------------------------------------------------------------------------
7575
- `string` -⠀the string to check
7676
- `char` -⠀the character to check for repetition"""
@@ -80,7 +80,7 @@ def single_char_repeats(cls, string: str, char: str, /) -> int:
8080
if len(string) == string.count(char):
8181
return string.count(char)
8282
else:
83-
return False
83+
return 0
8484

8585
@classmethod
8686
def decompose(cls, case_string: str, /, seps: str = "-_", *, lower_all: bool = True) -> list[str]:

tests/test_string.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ def test_is_empty():
6464

6565

6666
def test_single_char_repeats():
67-
assert String.single_char_repeats("aaaaa", "a") == 5
6867
assert String.single_char_repeats("-----", "-") == 5
69-
assert String.single_char_repeats("bbbbb", "a") is False
70-
assert String.single_char_repeats("abcde", "a") is False
7168
assert String.single_char_repeats("", "a") == 0
7269
assert String.single_char_repeats("a", "a") == 1
73-
assert String.single_char_repeats("aaaba", "a") is False
70+
assert String.single_char_repeats("aaaaa", "a") == 5
71+
assert String.single_char_repeats("aaaba", "a") == 0
72+
assert String.single_char_repeats("abcde", "a") == 0
73+
assert String.single_char_repeats("bbbbb", "a") == 0
7474

7575

7676
def test_decompose():

0 commit comments

Comments
 (0)