We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
In number_input, min_value & max_value format override format string and raises no warning
# Summary

Regardless of the format string specified by the user, actual format used will be based on min_value and max_value

# Steps to reproduce

The following code presents a warning:
`weight = st.number_input("Today's weight:", min_value=50.0, max_value=750.0, format="%d")`
_Warning: NumberInput value below is float, but format %d displays as integer._

I believe that's intended behavior. However, the inverse condition doesn't produce a warning or error.
```
weight = st.number_input("Today's weight:", min_value=50, max_value=750, format="%4.1f")
print(weight)
st.write("Echoing weight: ", weight)

```
If the input value is, for example, 170.4, the weight value will be 170, shown by both print() and st.write(), based on the interpreted format of min and max values. Note that this line of code does not produce any error or warning. The user (at least in my case) assumed min_value and max_value would be raised to float rather than ignoring format. I couldn't figure out why my input was being reduced from 170.4 to 170

The correct code works fine
`weight = st.number_input("Today's weight:", min_value=50.0, max_value=750.0, format="%4.1f")`

## Expected behavior:

A warning in both cases, not just one or the other. Maybe:
_Warning: NumberInput value below is integer, format %f lowered to match integer._

## Actual behavior:

No warning produced, seems like there should be. 
Sorry, already explained in the Steps to Reproduce section

## Is this a regression?

No (not that I know of)

# Debug info

- Streamlit version: (get it with `$ streamlit version`) 0.64.0
- Python version: (get it with `$ python --version`) 3.7.7
- Using Conda
- OS version: Windows 10 64bit
- Browser version: Chrome Version 84.0.4147.105 (Official Build) (64-bit)

# Additional information



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/streamlit/elements/number_input.py`
Content:
```
1 # Copyright 2018-2020 Streamlit Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import numbers
16 from typing import cast
17 
18 import streamlit
19 from streamlit.errors import StreamlitAPIException
20 from streamlit.js_number import JSNumber, JSNumberBoundsException
21 from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
22 from .utils import register_widget, NoValue
23 
24 
25 class NumberInputMixin:
26     def number_input(
27         self,
28         label,
29         min_value=None,
30         max_value=None,
31         value=NoValue(),
32         step=None,
33         format=None,
34         key=None,
35     ):
36         """Display a numeric input widget.
37 
38         Parameters
39         ----------
40         label : str or None
41             A short label explaining to the user what this input is for.
42         min_value : int or float or None
43             The minimum permitted value.
44             If None, there will be no minimum.
45         max_value : int or float or None
46             The maximum permitted value.
47             If None, there will be no maximum.
48         value : int or float or None
49             The value of this widget when it first renders.
50             Defaults to min_value, or 0.0 if min_value is None
51         step : int or float or None
52             The stepping interval.
53             Defaults to 1 if the value is an int, 0.01 otherwise.
54             If the value is not specified, the format parameter will be used.
55         format : str or None
56             A printf-style format string controlling how the interface should
57             display numbers. Output must be purely numeric. This does not impact
58             the return value. Valid formatters: %d %e %f %g %i
59         key : str
60             An optional string to use as the unique key for the widget.
61             If this is omitted, a key will be generated for the widget
62             based on its content. Multiple widgets of the same type may
63             not share the same key.
64 
65         Returns
66         -------
67         int or float
68             The current value of the numeric input widget. The return type
69             will match the data type of the value parameter.
70 
71         Example
72         -------
73         >>> number = st.number_input('Insert a number')
74         >>> st.write('The current number is ', number)
75         """
76 
77         if isinstance(value, NoValue):
78             if min_value is not None:
79                 value = min_value
80             else:
81                 value = 0.0  # We set a float as default
82 
83         int_value = isinstance(value, numbers.Integral)
84         float_value = isinstance(value, float)
85 
86         if value is None:
87             raise StreamlitAPIException(
88                 "Default value for number_input should be an int or a float."
89             )
90         else:
91             if format is None:
92                 format = "%d" if int_value else "%0.2f"
93 
94             if format in ["%d", "%u", "%i"] and float_value:
95                 # Warn user to check if displaying float as int was really intended.
96                 import streamlit as st
97 
98                 st.warning(
99                     "Warning: NumberInput value below is float, but format {} displays as integer.".format(
100                         format
101                     )
102                 )
103 
104             if step is None:
105                 step = 1 if int_value else 0.01
106 
107         try:
108             float(format % 2)
109         except (TypeError, ValueError):
110             raise StreamlitAPIException(
111                 "Format string for st.number_input contains invalid characters: %s"
112                 % format
113             )
114 
115         # Ensure that all arguments are of the same type.
116         args = [min_value, max_value, step]
117 
118         int_args = all(
119             map(
120                 lambda a: (
121                     isinstance(a, numbers.Integral) or isinstance(a, type(None))
122                 ),
123                 args,
124             )
125         )
126         float_args = all(
127             map(lambda a: (isinstance(a, float) or isinstance(a, type(None))), args)
128         )
129 
130         if not int_args and not float_args:
131             raise StreamlitAPIException(
132                 "All arguments must be of the same type."
133                 "\n`value` has %(value_type)s type."
134                 "\n`min_value` has %(min_type)s type."
135                 "\n`max_value` has %(max_type)s type."
136                 % {
137                     "value_type": type(value).__name__,
138                     "min_type": type(min_value).__name__,
139                     "max_type": type(max_value).__name__,
140                 }
141             )
142 
143         # Ensure that the value matches arguments' types.
144         all_ints = int_value and int_args
145         all_floats = float_value and float_args
146 
147         if not all_ints and not all_floats:
148             raise StreamlitAPIException(
149                 "All numerical arguments must be of the same type."
150                 "\n`value` has %(value_type)s type."
151                 "\n`min_value` has %(min_type)s type."
152                 "\n`max_value` has %(max_type)s type."
153                 "\n`step` has %(step_type)s type."
154                 % {
155                     "value_type": type(value).__name__,
156                     "min_type": type(min_value).__name__,
157                     "max_type": type(max_value).__name__,
158                     "step_type": type(step).__name__,
159                 }
160             )
161 
162         if (min_value and min_value > value) or (max_value and max_value < value):
163             raise StreamlitAPIException(
164                 "The default `value` of %(value)s "
165                 "must lie between the `min_value` of %(min)s "
166                 "and the `max_value` of %(max)s, inclusively."
167                 % {"value": value, "min": min_value, "max": max_value}
168             )
169 
170         # Bounds checks. JSNumber produces human-readable exceptions that
171         # we simply re-package as StreamlitAPIExceptions.
172         try:
173             if all_ints:
174                 if min_value is not None:
175                     JSNumber.validate_int_bounds(min_value, "`min_value`")
176                 if max_value is not None:
177                     JSNumber.validate_int_bounds(max_value, "`max_value`")
178                 if step is not None:
179                     JSNumber.validate_int_bounds(step, "`step`")
180                 JSNumber.validate_int_bounds(value, "`value`")
181             else:
182                 if min_value is not None:
183                     JSNumber.validate_float_bounds(min_value, "`min_value`")
184                 if max_value is not None:
185                     JSNumber.validate_float_bounds(max_value, "`max_value`")
186                 if step is not None:
187                     JSNumber.validate_float_bounds(step, "`step`")
188                 JSNumber.validate_float_bounds(value, "`value`")
189         except JSNumberBoundsException as e:
190             raise StreamlitAPIException(str(e))
191 
192         number_input_proto = NumberInputProto()
193         number_input_proto.data_type = (
194             NumberInputProto.INT if all_ints else NumberInputProto.FLOAT
195         )
196         number_input_proto.label = label
197         number_input_proto.default = value
198 
199         if min_value is not None:
200             number_input_proto.min = min_value
201             number_input_proto.has_min = True
202 
203         if max_value is not None:
204             number_input_proto.max = max_value
205             number_input_proto.has_max = True
206 
207         if step is not None:
208             number_input_proto.step = step
209 
210         if format is not None:
211             number_input_proto.format = format
212 
213         ui_value = register_widget("number_input", number_input_proto, user_key=key)
214 
215         return_value = ui_value if ui_value is not None else value
216         return self.dg._enqueue("number_input", number_input_proto, return_value)
217 
218     @property
219     def dg(self) -> "streamlit.delta_generator.DeltaGenerator":
220         """Get our DeltaGenerator."""
221         return cast("streamlit.delta_generator.DeltaGenerator", self)
222
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lib/streamlit/elements/number_input.py b/lib/streamlit/elements/number_input.py
--- a/lib/streamlit/elements/number_input.py
+++ b/lib/streamlit/elements/number_input.py
@@ -55,7 +55,7 @@
         format : str or None
             A printf-style format string controlling how the interface should
             display numbers. Output must be purely numeric. This does not impact
-            the return value. Valid formatters: %d %e %f %g %i
+            the return value. Valid formatters: %d %e %f %g %i %u
         key : str
             An optional string to use as the unique key for the widget.
             If this is omitted, a key will be generated for the widget
@@ -91,14 +91,20 @@
             if format is None:
                 format = "%d" if int_value else "%0.2f"
 
+            # Warn user if they format an int type as a float or vice versa.
             if format in ["%d", "%u", "%i"] and float_value:
-                # Warn user to check if displaying float as int was really intended.
                 import streamlit as st
 
                 st.warning(
-                    "Warning: NumberInput value below is float, but format {} displays as integer.".format(
-                        format
-                    )
+                    "Warning: NumberInput value below has type float,"
+                    f" but format {format} displays as integer."
+                )
+            elif format[-1] == "f" and int_value:
+                import streamlit as st
+
+                st.warning(
+                    "Warning: NumberInput value below has type int so is"
+                    f" displayed as int despite format string {format}."
                 )
 
             if step is None:

{"golden_diff": "diff --git a/lib/streamlit/elements/number_input.py b/lib/streamlit/elements/number_input.py\n--- a/lib/streamlit/elements/number_input.py\n+++ b/lib/streamlit/elements/number_input.py\n@@ -55,7 +55,7 @@\n         format : str or None\n             A printf-style format string controlling how the interface should\n             display numbers. Output must be purely numeric. This does not impact\n-            the return value. Valid formatters: %d %e %f %g %i\n+            the return value. Valid formatters: %d %e %f %g %i %u\n         key : str\n             An optional string to use as the unique key for the widget.\n             If this is omitted, a key will be generated for the widget\n@@ -91,14 +91,20 @@\n             if format is None:\n                 format = \"%d\" if int_value else \"%0.2f\"\n \n+            # Warn user if they format an int type as a float or vice versa.\n             if format in [\"%d\", \"%u\", \"%i\"] and float_value:\n-                # Warn user to check if displaying float as int was really intended.\n                 import streamlit as st\n \n                 st.warning(\n-                    \"Warning: NumberInput value below is float, but format {} displays as integer.\".format(\n-                        format\n-                    )\n+                    \"Warning: NumberInput value below has type float,\"\n+                    f\" but format {format} displays as integer.\"\n+                )\n+            elif format[-1] == \"f\" and int_value:\n+                import streamlit as st\n+\n+                st.warning(\n+                    \"Warning: NumberInput value below has type int so is\"\n+                    f\" displayed as int despite format string {format}.\"\n                 )\n \n             if step is None:\n", "issue": "In number_input, min_value & max_value format override format string and raises no warning\n# Summary\r\n\r\nRegardless of the format string specified by the user, actual format used will be based on min_value and max_value\r\n\r\n# Steps to reproduce\r\n\r\nThe following code presents a warning:\r\n`weight = st.number_input(\"Today's weight:\", min_value=50.0, max_value=750.0, format=\"%d\")`\r\n_Warning: NumberInput value below is float, but format %d displays as integer._\r\n\r\nI believe that's intended behavior. However, the inverse condition doesn't produce a warning or error.\r\n```\r\nweight = st.number_input(\"Today's weight:\", min_value=50, max_value=750, format=\"%4.1f\")\r\nprint(weight)\r\nst.write(\"Echoing weight: \", weight)\r\n\r\n```\r\nIf the input value is, for example, 170.4, the weight value will be 170, shown by both print() and st.write(), based on the interpreted format of min and max values. Note that this line of code does not produce any error or warning. The user (at least in my case) assumed min_value and max_value would be raised to float rather than ignoring format. I couldn't figure out why my input was being reduced from 170.4 to 170\r\n\r\nThe correct code works fine\r\n`weight = st.number_input(\"Today's weight:\", min_value=50.0, max_value=750.0, format=\"%4.1f\")`\r\n\r\n## Expected behavior:\r\n\r\nA warning in both cases, not just one or the other. Maybe:\r\n_Warning: NumberInput value below is integer, format %f lowered to match integer._\r\n\r\n## Actual behavior:\r\n\r\nNo warning produced, seems like there should be. \r\nSorry, already explained in the Steps to Reproduce section\r\n\r\n## Is this a regression?\r\n\r\nNo (not that I know of)\r\n\r\n# Debug info\r\n\r\n- Streamlit version: (get it with `$ streamlit version`) 0.64.0\r\n- Python version: (get it with `$ python --version`) 3.7.7\r\n- Using Conda\r\n- OS version: Windows 10 64bit\r\n- Browser version: Chrome Version 84.0.4147.105 (Official Build) (64-bit)\r\n\r\n# Additional information\r\n\r\n\n", "before_files": [{"content": "# Copyright 2018-2020 Streamlit Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport numbers\nfrom typing import cast\n\nimport streamlit\nfrom streamlit.errors import StreamlitAPIException\nfrom streamlit.js_number import JSNumber, JSNumberBoundsException\nfrom streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto\nfrom .utils import register_widget, NoValue\n\n\nclass NumberInputMixin:\n    def number_input(\n        self,\n        label,\n        min_value=None,\n        max_value=None,\n        value=NoValue(),\n        step=None,\n        format=None,\n        key=None,\n    ):\n        \"\"\"Display a numeric input widget.\n\n        Parameters\n        ----------\n        label : str or None\n            A short label explaining to the user what this input is for.\n        min_value : int or float or None\n            The minimum permitted value.\n            If None, there will be no minimum.\n        max_value : int or float or None\n            The maximum permitted value.\n            If None, there will be no maximum.\n        value : int or float or None\n            The value of this widget when it first renders.\n            Defaults to min_value, or 0.0 if min_value is None\n        step : int or float or None\n            The stepping interval.\n            Defaults to 1 if the value is an int, 0.01 otherwise.\n            If the value is not specified, the format parameter will be used.\n        format : str or None\n            A printf-style format string controlling how the interface should\n            display numbers. Output must be purely numeric. This does not impact\n            the return value. Valid formatters: %d %e %f %g %i\n        key : str\n            An optional string to use as the unique key for the widget.\n            If this is omitted, a key will be generated for the widget\n            based on its content. Multiple widgets of the same type may\n            not share the same key.\n\n        Returns\n        -------\n        int or float\n            The current value of the numeric input widget. The return type\n            will match the data type of the value parameter.\n\n        Example\n        -------\n        >>> number = st.number_input('Insert a number')\n        >>> st.write('The current number is ', number)\n        \"\"\"\n\n        if isinstance(value, NoValue):\n            if min_value is not None:\n                value = min_value\n            else:\n                value = 0.0  # We set a float as default\n\n        int_value = isinstance(value, numbers.Integral)\n        float_value = isinstance(value, float)\n\n        if value is None:\n            raise StreamlitAPIException(\n                \"Default value for number_input should be an int or a float.\"\n            )\n        else:\n            if format is None:\n                format = \"%d\" if int_value else \"%0.2f\"\n\n            if format in [\"%d\", \"%u\", \"%i\"] and float_value:\n                # Warn user to check if displaying float as int was really intended.\n                import streamlit as st\n\n                st.warning(\n                    \"Warning: NumberInput value below is float, but format {} displays as integer.\".format(\n                        format\n                    )\n                )\n\n            if step is None:\n                step = 1 if int_value else 0.01\n\n        try:\n            float(format % 2)\n        except (TypeError, ValueError):\n            raise StreamlitAPIException(\n                \"Format string for st.number_input contains invalid characters: %s\"\n                % format\n            )\n\n        # Ensure that all arguments are of the same type.\n        args = [min_value, max_value, step]\n\n        int_args = all(\n            map(\n                lambda a: (\n                    isinstance(a, numbers.Integral) or isinstance(a, type(None))\n                ),\n                args,\n            )\n        )\n        float_args = all(\n            map(lambda a: (isinstance(a, float) or isinstance(a, type(None))), args)\n        )\n\n        if not int_args and not float_args:\n            raise StreamlitAPIException(\n                \"All arguments must be of the same type.\"\n                \"\\n`value` has %(value_type)s type.\"\n                \"\\n`min_value` has %(min_type)s type.\"\n                \"\\n`max_value` has %(max_type)s type.\"\n                % {\n                    \"value_type\": type(value).__name__,\n                    \"min_type\": type(min_value).__name__,\n                    \"max_type\": type(max_value).__name__,\n                }\n            )\n\n        # Ensure that the value matches arguments' types.\n        all_ints = int_value and int_args\n        all_floats = float_value and float_args\n\n        if not all_ints and not all_floats:\n            raise StreamlitAPIException(\n                \"All numerical arguments must be of the same type.\"\n                \"\\n`value` has %(value_type)s type.\"\n                \"\\n`min_value` has %(min_type)s type.\"\n                \"\\n`max_value` has %(max_type)s type.\"\n                \"\\n`step` has %(step_type)s type.\"\n                % {\n                    \"value_type\": type(value).__name__,\n                    \"min_type\": type(min_value).__name__,\n                    \"max_type\": type(max_value).__name__,\n                    \"step_type\": type(step).__name__,\n                }\n            )\n\n        if (min_value and min_value > value) or (max_value and max_value < value):\n            raise StreamlitAPIException(\n                \"The default `value` of %(value)s \"\n                \"must lie between the `min_value` of %(min)s \"\n                \"and the `max_value` of %(max)s, inclusively.\"\n                % {\"value\": value, \"min\": min_value, \"max\": max_value}\n            )\n\n        # Bounds checks. JSNumber produces human-readable exceptions that\n        # we simply re-package as StreamlitAPIExceptions.\n        try:\n            if all_ints:\n                if min_value is not None:\n                    JSNumber.validate_int_bounds(min_value, \"`min_value`\")\n                if max_value is not None:\n                    JSNumber.validate_int_bounds(max_value, \"`max_value`\")\n                if step is not None:\n                    JSNumber.validate_int_bounds(step, \"`step`\")\n                JSNumber.validate_int_bounds(value, \"`value`\")\n            else:\n                if min_value is not None:\n                    JSNumber.validate_float_bounds(min_value, \"`min_value`\")\n                if max_value is not None:\n                    JSNumber.validate_float_bounds(max_value, \"`max_value`\")\n                if step is not None:\n                    JSNumber.validate_float_bounds(step, \"`step`\")\n                JSNumber.validate_float_bounds(value, \"`value`\")\n        except JSNumberBoundsException as e:\n            raise StreamlitAPIException(str(e))\n\n        number_input_proto = NumberInputProto()\n        number_input_proto.data_type = (\n            NumberInputProto.INT if all_ints else NumberInputProto.FLOAT\n        )\n        number_input_proto.label = label\n        number_input_proto.default = value\n\n        if min_value is not None:\n            number_input_proto.min = min_value\n            number_input_proto.has_min = True\n\n        if max_value is not None:\n            number_input_proto.max = max_value\n            number_input_proto.has_max = True\n\n        if step is not None:\n            number_input_proto.step = step\n\n        if format is not None:\n            number_input_proto.format = format\n\n        ui_value = register_widget(\"number_input\", number_input_proto, user_key=key)\n\n        return_value = ui_value if ui_value is not None else value\n        return self.dg._enqueue(\"number_input\", number_input_proto, return_value)\n\n    @property\n    def dg(self) -> \"streamlit.delta_generator.DeltaGenerator\":\n        \"\"\"Get our DeltaGenerator.\"\"\"\n        return cast(\"streamlit.delta_generator.DeltaGenerator\", self)\n", "path": "lib/streamlit/elements/number_input.py"}], "after_files": [{"content": "# Copyright 2018-2020 Streamlit Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport numbers\nfrom typing import cast\n\nimport streamlit\nfrom streamlit.errors import StreamlitAPIException\nfrom streamlit.js_number import JSNumber, JSNumberBoundsException\nfrom streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto\nfrom .utils import register_widget, NoValue\n\n\nclass NumberInputMixin:\n    def number_input(\n        self,\n        label,\n        min_value=None,\n        max_value=None,\n        value=NoValue(),\n        step=None,\n        format=None,\n        key=None,\n    ):\n        \"\"\"Display a numeric input widget.\n\n        Parameters\n        ----------\n        label : str or None\n            A short label explaining to the user what this input is for.\n        min_value : int or float or None\n            The minimum permitted value.\n            If None, there will be no minimum.\n        max_value : int or float or None\n            The maximum permitted value.\n            If None, there will be no maximum.\n        value : int or float or None\n            The value of this widget when it first renders.\n            Defaults to min_value, or 0.0 if min_value is None\n        step : int or float or None\n            The stepping interval.\n            Defaults to 1 if the value is an int, 0.01 otherwise.\n            If the value is not specified, the format parameter will be used.\n        format : str or None\n            A printf-style format string controlling how the interface should\n            display numbers. Output must be purely numeric. This does not impact\n            the return value. Valid formatters: %d %e %f %g %i %u\n        key : str\n            An optional string to use as the unique key for the widget.\n            If this is omitted, a key will be generated for the widget\n            based on its content. Multiple widgets of the same type may\n            not share the same key.\n\n        Returns\n        -------\n        int or float\n            The current value of the numeric input widget. The return type\n            will match the data type of the value parameter.\n\n        Example\n        -------\n        >>> number = st.number_input('Insert a number')\n        >>> st.write('The current number is ', number)\n        \"\"\"\n\n        if isinstance(value, NoValue):\n            if min_value is not None:\n                value = min_value\n            else:\n                value = 0.0  # We set a float as default\n\n        int_value = isinstance(value, numbers.Integral)\n        float_value = isinstance(value, float)\n\n        if value is None:\n            raise StreamlitAPIException(\n                \"Default value for number_input should be an int or a float.\"\n            )\n        else:\n            if format is None:\n                format = \"%d\" if int_value else \"%0.2f\"\n\n            # Warn user if they format an int type as a float or vice versa.\n            if format in [\"%d\", \"%u\", \"%i\"] and float_value:\n                import streamlit as st\n\n                st.warning(\n                    \"Warning: NumberInput value below has type float,\"\n                    f\" but format {format} displays as integer.\"\n                )\n            elif format[-1] == \"f\" and int_value:\n                import streamlit as st\n\n                st.warning(\n                    \"Warning: NumberInput value below has type int so is\"\n                    f\" displayed as int despite format string {format}.\"\n                )\n\n            if step is None:\n                step = 1 if int_value else 0.01\n\n        try:\n            float(format % 2)\n        except (TypeError, ValueError):\n            raise StreamlitAPIException(\n                \"Format string for st.number_input contains invalid characters: %s\"\n                % format\n            )\n\n        # Ensure that all arguments are of the same type.\n        args = [min_value, max_value, step]\n\n        int_args = all(\n            map(\n                lambda a: (\n                    isinstance(a, numbers.Integral) or isinstance(a, type(None))\n                ),\n                args,\n            )\n        )\n        float_args = all(\n            map(lambda a: (isinstance(a, float) or isinstance(a, type(None))), args)\n        )\n\n        if not int_args and not float_args:\n            raise StreamlitAPIException(\n                \"All arguments must be of the same type.\"\n                \"\\n`value` has %(value_type)s type.\"\n                \"\\n`min_value` has %(min_type)s type.\"\n                \"\\n`max_value` has %(max_type)s type.\"\n                % {\n                    \"value_type\": type(value).__name__,\n                    \"min_type\": type(min_value).__name__,\n                    \"max_type\": type(max_value).__name__,\n                }\n            )\n\n        # Ensure that the value matches arguments' types.\n        all_ints = int_value and int_args\n        all_floats = float_value and float_args\n\n        if not all_ints and not all_floats:\n            raise StreamlitAPIException(\n                \"All numerical arguments must be of the same type.\"\n                \"\\n`value` has %(value_type)s type.\"\n                \"\\n`min_value` has %(min_type)s type.\"\n                \"\\n`max_value` has %(max_type)s type.\"\n                \"\\n`step` has %(step_type)s type.\"\n                % {\n                    \"value_type\": type(value).__name__,\n                    \"min_type\": type(min_value).__name__,\n                    \"max_type\": type(max_value).__name__,\n                    \"step_type\": type(step).__name__,\n                }\n            )\n\n        if (min_value and min_value > value) or (max_value and max_value < value):\n            raise StreamlitAPIException(\n                \"The default `value` of %(value)s \"\n                \"must lie between the `min_value` of %(min)s \"\n                \"and the `max_value` of %(max)s, inclusively.\"\n                % {\"value\": value, \"min\": min_value, \"max\": max_value}\n            )\n\n        # Bounds checks. JSNumber produces human-readable exceptions that\n        # we simply re-package as StreamlitAPIExceptions.\n        try:\n            if all_ints:\n                if min_value is not None:\n                    JSNumber.validate_int_bounds(min_value, \"`min_value`\")\n                if max_value is not None:\n                    JSNumber.validate_int_bounds(max_value, \"`max_value`\")\n                if step is not None:\n                    JSNumber.validate_int_bounds(step, \"`step`\")\n                JSNumber.validate_int_bounds(value, \"`value`\")\n            else:\n                if min_value is not None:\n                    JSNumber.validate_float_bounds(min_value, \"`min_value`\")\n                if max_value is not None:\n                    JSNumber.validate_float_bounds(max_value, \"`max_value`\")\n                if step is not None:\n                    JSNumber.validate_float_bounds(step, \"`step`\")\n                JSNumber.validate_float_bounds(value, \"`value`\")\n        except JSNumberBoundsException as e:\n            raise StreamlitAPIException(str(e))\n\n        number_input_proto = NumberInputProto()\n        number_input_proto.data_type = (\n            NumberInputProto.INT if all_ints else NumberInputProto.FLOAT\n        )\n        number_input_proto.label = label\n        number_input_proto.default = value\n\n        if min_value is not None:\n            number_input_proto.min = min_value\n            number_input_proto.has_min = True\n\n        if max_value is not None:\n            number_input_proto.max = max_value\n            number_input_proto.has_max = True\n\n        if step is not None:\n            number_input_proto.step = step\n\n        if format is not None:\n            number_input_proto.format = format\n\n        ui_value = register_widget(\"number_input\", number_input_proto, user_key=key)\n\n        return_value = ui_value if ui_value is not None else value\n        return self.dg._enqueue(\"number_input\", number_input_proto, return_value)\n\n    @property\n    def dg(self) -> \"streamlit.delta_generator.DeltaGenerator\":\n        \"\"\"Get our DeltaGenerator.\"\"\"\n        return cast(\"streamlit.delta_generator.DeltaGenerator\", self)\n", "path": "lib/streamlit/elements/number_input.py"}]}