Repository: joke2k/faker

Issue:
ValueError: empty range for pyfloat
* Faker version: 14.0.0
* OS: macOS 12.5 (Monterey)

pyfloat throws ValueError when min_value and max_value have the same left digits. 

### Steps to reproduce

```
from faker import Faker

fake = Faker()

fake.pyfloat(min_value=1.25, max_value=1.75)
```

### Expected behavior

pyfloat returns a float between min_value and max_value

### Actual behavior

pyfloat throws exception

```
ValueError: empty range for randrange() (1, 1, 0)
```


Comments:

Patch:
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 6d2394f1..037b8645 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 15.1.1
+current_version = 15.1.2
 files = VERSION faker/__init__.py docs/conf.py
 commit = True
 tag = True
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d66f603..207f95ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 ## Changelog
 
+### [v15.1.2 - 2022-11-01](https://github.com/joke2k/faker/compare/v15.1.1...v15.1.2)
+
+* Fix missing return in `en_US` `state_abbr`. Thanks @AssenD.
+
 ### [v15.1.1 - 2022-10-13](https://github.com/joke2k/faker/compare/v15.1.0...v15.1.1)
 
 * Fix ImportError on python <3.7.2. Thanks @matthewhughes934.
diff --git a/VERSION b/VERSION
index 68a28303..0a75ce5d 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-15.1.1
+15.1.2
diff --git a/docs/conf.py b/docs/conf.py
index 5e436041..278b69db 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -51,9 +51,9 @@ copyright = "2014, Daniele Faraglia"
 # built documents.
 #
 # The short X.Y version.
-version = "15.1.1"
+version = "15.1.2"
 # The full version, including alpha/beta/rc tags.
-release = "15.1.1"
+release = "15.1.2"
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/faker/__init__.py b/faker/__init__.py
index 12140975..1ce84021 100644
--- a/faker/__init__.py
+++ b/faker/__init__.py
@@ -2,6 +2,6 @@ from faker.factory import Factory
 from faker.generator import Generator
 from faker.proxy import Faker
 
-VERSION = "15.1.1"
+VERSION = "15.1.2"
 
 __all__ = ("Factory", "Generator", "Faker")
diff --git a/faker/providers/address/en_US/__init__.py b/faker/providers/address/en_US/__init__.py
index 82c1cac0..4242e781 100644
--- a/faker/providers/address/en_US/__init__.py
+++ b/faker/providers/address/en_US/__init__.py
@@ -493,7 +493,7 @@ class Provider(AddressProvider):
             If False, only states will be returned.
         """
         if include_territories:
-            self.random_element(self.states_and_territories_abbr)
+            return self.random_element(self.states_and_territories_abbr)
         return self.random_element(self.states_abbr)
 
     def postcode(self) -> str:
diff --git a/faker/providers/python/__init__.py b/faker/providers/python/__init__.py
index 28128635..13926cf2 100644
--- a/faker/providers/python/__init__.py
+++ b/faker/providers/python/__init__.py
@@ -58,7 +58,13 @@ class Provider(BaseProvider):
     def pybool(self) -> bool:
         return self.random_int(0, 1) == 1
 
-    def pystr(self, min_chars: Optional[int] = None, max_chars: int = 20, prefix: str = "", suffix: str = "") -> str:
+    def pystr(
+        self,
+        min_chars: Optional[int] = None,
+        max_chars: int = 20,
+        prefix: str = "",
+        suffix: str = "",
+    ) -> str:
         """
         Generates a random string of upper and lowercase letters.
         :return: Random of random length between min and max characters.
@@ -162,6 +168,11 @@ class Provider(BaseProvider):
             result = min(result, 10**left_digits - 1)
             result = max(result, -(10**left_digits + 1))
 
+        # It's possible for the result to end up > than max_value
+        # This is a quick hack to ensure result is always smaller.
+        if max_value is not None:
+            if result > max_value:
+                result = result - (result - max_value)
         return result
 
     def _safe_random_int(self, min_value: float, max_value: float, positive: bool) -> int:
@@ -178,7 +189,11 @@ class Provider(BaseProvider):
         if min_value == max_value:
             return self._safe_random_int(orig_min_value, orig_max_value, positive)
         else:
-            return self.random_int(int(min_value), int(max_value - 1))
+            min_value = int(min_value)
+            max_value = int(max_value - 1)
+            if max_value < min_value:
+                max_value += 1
+            return self.random_int(min_value, max_value)
 
     def pyint(self, min_value: int = 0, max_value: int = 9999, step: int = 1) -> int:
         return self.generator.random_int(min_value, max_value, step=step)
@@ -385,7 +400,10 @@ class Provider(BaseProvider):
         )
 
     def pystruct(
-        self, count: int = 10, value_types: Optional[TypesSpec] = None, allowed_types: Optional[TypesSpec] = None
+        self,
+        count: int = 10,
+        value_types: Optional[TypesSpec] = None,
+        allowed_types: Optional[TypesSpec] = None,
     ) -> Tuple[List, Dict, Dict]:
         value_types: TypesSpec = self._check_signature(value_types, allowed_types)
 


Test patch:
diff --git a/tests/providers/test_python.py b/tests/providers/test_python.py
index 39c067b7..c3088a8e 100644
--- a/tests/providers/test_python.py
+++ b/tests/providers/test_python.py
@@ -228,6 +228,9 @@ class TestPyfloat(unittest.TestCase):
         """
         self.fake.pyfloat(min_value=-1.0, max_value=1.0)
 
+    def test_float_min_and_max_value_with_same_whole(self):
+        self.fake.pyfloat(min_value=2.3, max_value=2.5)
+
 
 class TestPydecimal(unittest.TestCase):
     def setUp(self):