|
2 | 2 | # SPDX-License-Identifier: MIT |
3 | 3 | # The MIT License (MIT) |
4 | 4 | # |
5 | | -# Copyright © 2014-2016 Tim Case <timbielawa@gmail.com> |
| 5 | +# Copyright © 2014-2026 Tim Case <bitmath@lnx.cx> |
6 | 6 | # See GitHub Contributors Graph for more information |
7 | 7 | # |
8 | 8 | # Permission is hereby granted, free of charge, to any person |
|
24 | 24 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
25 | 25 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
26 | 26 | # SOFTWARE. |
27 | | -# pylint: disable=bad-continuation,missing-docstring,invalid-name,line-too-long |
| 27 | +# pylint: disable=line-too-long |
28 | 28 |
|
29 | 29 | """Reference material: |
30 | 30 | The bitmath homepage is located at: |
@@ -785,17 +785,6 @@ def __ge__(self, other): |
785 | 785 |
|
786 | 786 | # Reference: https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types |
787 | 787 |
|
788 | | - """These methods are called to implement the binary arithmetic |
789 | | -operations (+, -, *, //, %, divmod(), pow(), **, <<, >>, &, ^, |). For |
790 | | -instance, to evaluate the expression x + y, where x is an instance of |
791 | | -a class that has an __add__() method, x.__add__(y) is called. The |
792 | | -__divmod__() method should be the equivalent to using __floordiv__() |
793 | | -and __mod__(); it should not be related to __truediv__() (described |
794 | | -below). Note that __pow__() should be defined to accept an optional |
795 | | -third argument if the ternary version of the built-in pow() function |
796 | | -is to be supported.object.__complex__(self) |
797 | | -""" |
798 | | - |
799 | 788 | def __add__(self, other): |
800 | 789 | """Supported operations with result types: |
801 | 790 |
|
@@ -895,20 +884,6 @@ def __divmod__(self, other): |
895 | 884 |
|
896 | 885 | ################################################################## |
897 | 886 |
|
898 | | - """These methods are called to implement the binary arithmetic |
899 | | -operations (+, -, *, /, %, divmod(), pow(), **, <<, >>, &, ^, |) with |
900 | | -reflected (swapped) operands. These functions are only called if the |
901 | | -left operand does not support the corresponding operation and the |
902 | | -operands are of different types. [2] For instance, to evaluate the |
903 | | -expression x - y, where y is an instance of a class that has an |
904 | | -__rsub__() method, y.__rsub__(x) is called if x.__sub__(y) returns |
905 | | -NotImplemented. |
906 | | -
|
907 | | -These are the add/sub/mul/div methods for syntax where a number type |
908 | | -is given for the LTYPE and a bitmath object is given for the |
909 | | -RTYPE. E.g., 3 * MiB(3), or 10 / GB(42) |
910 | | -""" |
911 | | - |
912 | 887 | def __radd__(self, other): |
913 | 888 | # Special case: 0 + bm = bm (identity element, enables built-in sum()) |
914 | 889 | if other == 0: |
@@ -1663,10 +1638,7 @@ def parse_string(s: str | numbers.Number, system: int = NIST, strict: bool = Tru |
1663 | 1638 | val = float(val) |
1664 | 1639 | except ValueError: |
1665 | 1640 | raise |
1666 | | - try: |
1667 | | - return unit_class(val) |
1668 | | - except: # pragma: no cover |
1669 | | - raise ValueError(f"Can't parse string {s} into a bitmath object") |
| 1641 | + return unit_class(val) |
1670 | 1642 |
|
1671 | 1643 | else: |
1672 | 1644 | # strict=False path (formerly parse_string_unsafe) |
|
0 commit comments