Skip to content

Commit e1110eb

Browse files
CorieWcabljac
andauthored
fix: FloatParam marked private as unsupported in CLI (#221)
Co-authored-by: Jacob Cable <[email protected]>
1 parent d2c8bb0 commit e1110eb

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

.pylintrc

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ disable=abstract-method,
147147
xrange-builtin,
148148
zip-builtin-not-iterating,
149149
import-outside-toplevel,
150+
protected-access,
150151

151152

152153
[REPORTS]

src/firebase_functions/params.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,12 @@ def value(self) -> int:
344344

345345

346346
@_dataclasses.dataclass(frozen=True)
347-
class FloatParam(Param[float]):
348-
"""A parameter as a float value."""
347+
class _FloatParam(Param[float]):
348+
"""
349+
A parameter as a float value.
350+
Marked as private because it is not supported by firebase-tools yet.
351+
Unmark when it is supported.
352+
"""
349353

350354
@property
351355
def value(self) -> float:

src/firebase_functions/private/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _param_to_spec(
241241
spec_dict["type"] = "boolean"
242242
elif isinstance(param, _params.IntParam):
243243
spec_dict["type"] = "int"
244-
elif isinstance(param, _params.FloatParam):
244+
elif isinstance(param, _params._FloatParam):
245245
spec_dict["type"] = "float"
246246
elif isinstance(param, _params.SecretParam):
247247
spec_dict["type"] = "secret"

tests/test_manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
params=[
6666
_params.BoolParam("BOOL_TEST", default=False),
6767
_params.IntParam("INT_TEST", description="int_description"),
68-
_params.FloatParam("FLOAT_TEST", immutable=True),
68+
_params._FloatParam("FLOAT_TEST", immutable=True),
6969
_params.SecretParam("SECRET_TEST"),
7070
_params.StringParam("STRING_TEST"),
7171
_params.ListParam("LIST_TEST", default=["1", "2", "3"]),

tests/test_params.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,28 @@ class TestFloatParams:
5858
def test_float_param_value(self):
5959
"""Testing if float params correctly returns a value."""
6060
environ["FLOAT_VALUE_TEST"] = "123.456"
61-
assert params.FloatParam("FLOAT_VALUE_TEST",).value == 123.456, \
61+
assert params._FloatParam("FLOAT_VALUE_TEST",).value == 123.456, \
6262
"Failure, params value != 123.456"
6363

6464
def test_float_param_empty_default(self):
6565
"""Testing if float params defaults to empty float if no value and no default."""
66-
assert params.FloatParam("FLOAT_DEFAULT_TEST1").value == float(), \
66+
assert params._FloatParam("FLOAT_DEFAULT_TEST1").value == float(), \
6767
"Failure, params value is not float"
6868

6969
def test_float_param_default(self):
7070
"""Testing if float param defaults to provided default value."""
71-
assert params.FloatParam("FLOAT_DEFAULT_TEST2",
71+
assert params._FloatParam("FLOAT_DEFAULT_TEST2", \
7272
default=float(456.789)).value == 456.789, \
7373
"Failure, params default value != 456.789"
7474

7575
def test_float_param_equality(self):
7676
"""Test float equality."""
77-
assert (params.FloatParam("FLOAT_TEST1",
78-
default=123.456).equals(123.456).value
79-
is True), "Failure, equality check returned False"
80-
assert (params.FloatParam("FLOAT_TEST2",
81-
default=456.789).equals(123.456).value
82-
is False), "Failure, equality check returned False"
77+
assert (params._FloatParam("FLOAT_TEST1", \
78+
default=123.456).equals(123.456).value \
79+
is True), "Failure, equality check returned False"
80+
assert (params._FloatParam("FLOAT_TEST2", \
81+
default=456.789).equals(123.456).value \
82+
is False), "Failure, equality check returned False"
8383

8484

8585
class TestIntParams:

0 commit comments

Comments
 (0)