codecov-io: # [Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=h1) Report
> Merging [#188](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=desc) into [master](https://codecov.io/gh/Azure/msrest-for-python/commit/4a0a44ae6d1a0d8a196a7809d54f2a52c2c27479?src=pr&el=desc) will **increase** coverage by `0.06%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Azure/msrest-for-python/pull/188/graphs/tree.svg?width=650&token=Lny6ZO1MUF&height=150&src=pr)](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #188      +/-   ##
==========================================
+ Coverage   87.89%   87.95%   +0.06%     
==========================================
  Files          25       25              
  Lines        2593     2598       +5     
==========================================
+ Hits         2279     2285       +6     
+ Misses        314      313       -1
```


| [Impacted Files](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [msrest/exceptions.py](https://codecov.io/gh/Azure/msrest-for-python/pull/188/diff?src=pr&el=tree#diff-bXNyZXN0L2V4Y2VwdGlvbnMucHk=) | `98.73% <100%> (+0.08%)` | :arrow_up: |
| [msrest/serialization.py](https://codecov.io/gh/Azure/msrest-for-python/pull/188/diff?src=pr&el=tree#diff-bXNyZXN0L3NlcmlhbGl6YXRpb24ucHk=) | `91.22% <0%> (+0.1%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=footer). Last update [4a0a44a...3832c06](https://codecov.io/gh/Azure/msrest-for-python/pull/188?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/msrest/exceptions.py b/msrest/exceptions.py
index 31bedf0..dcd14d2 100644
--- a/msrest/exceptions.py
+++ b/msrest/exceptions.py
@@ -107,6 +107,13 @@ class ValidationError(ClientException):
         "type": "must be of type {!r}"
     }
 
+    @staticmethod
+    def _format_message(rule, reason, value):
+        if rule == "type" and value.startswith(r"{"):
+            internal_type = value.strip(r"{}")
+            value = "dict[str, {}]".format(internal_type)
+        return reason.format(value)
+
     def __init__(self, rule, target, value, *args, **kwargs):
         # type: (str, str, str, str, str) -> None
         self.rule = rule
@@ -114,7 +121,7 @@ class ValidationError(ClientException):
         message = "Parameter {!r} ".format(target)
         reason = self._messages.get(
             rule, "failed to meet validation requirement.")
-        message += reason.format(value)
+        message += self._format_message(rule, reason, value)
         super(ValidationError, self).__init__(message, *args, **kwargs)
 
 

Improve msrest exception message
msrest.exceptions : Parameter 'tags' must be of type '{str}'
diff --git a/tests/test_serialization.py b/tests/test_serialization.py
index 399d963..00d253c 100644
--- a/tests/test_serialization.py
+++ b/tests/test_serialization.py
@@ -709,6 +709,10 @@ class TestRuntimeSerialized(unittest.TestCase):
         with self.assertRaises(SerializationError):
             self.s._serialize(test_obj)
 
+        with pytest.raises(ValidationError) as err:
+            test_obj.validate()
+        assert "Parameter 'attr_e' must be of type 'dict[str, float]'" in str(err.value)
+
         test_obj.attr_e = {"value": "NotAFloat"}
 
         with self.assertRaises(SerializationError):
@@ -1290,7 +1294,7 @@ class TestRuntimeSerialized(unittest.TestCase):
             long_type = long
         except NameError:
             long_type = int
- 
+
 
         class TestModel(Model):
             _attribute_map = {'data': {'key': 'data', 'type': 'object'}}

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi==2025.1.31
charset-normalizer==3.4.1
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
isodate==0.7.2
-e git+https://github.com/Azure/msrest-for-python.git@4a0a44ae6d1a0d8a196a7809d54f2a52c2c27479#egg=msrest
oauthlib==3.2.2
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
requests==2.32.3
requests-oauthlib==2.0.0
tomli==2.2.1
urllib3==2.3.0

name: msrest-for-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - exceptiongroup==1.2.2
      - idna==3.10
      - iniconfig==2.1.0
      - isodate==0.7.2
      - oauthlib==3.2.2
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - requests==2.32.3
      - requests-oauthlib==2.0.0
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/msrest-for-python

tests/test_serialization.py::TestRuntimeSerialized::test_attr_dict_simple
tests/test_serialization.py::TestModelDeserialization::test_empty_enum_logs tests/test_serialization.py::TestModelDeserialization::test_model_kwargs tests/test_serialization.py::TestModelDeserialization::test_model_kwargs_logs tests/test_serialization.py::TestModelDeserialization::test_response tests/test_serialization.py::TestRuntimeSerialized::test_additional_properties tests/test_serialization.py::TestRuntimeSerialized::test_additional_properties_declared tests/test_serialization.py::TestRuntimeSerialized::test_additional_properties_manual tests/test_serialization.py::TestRuntimeSerialized::test_additional_properties_no_send tests/test_serialization.py::TestRuntimeSerialized::test_additional_properties_with_auto_model tests/test_serialization.py::TestRuntimeSerialized::test_attr_bool tests/test_serialization.py::TestRuntimeSerialized::test_attr_duration tests/test_serialization.py::TestRuntimeSerialized::test_attr_enum tests/test_serialization.py::TestRuntimeSerialized::test_attr_int tests/test_serialization.py::TestRuntimeSerialized::test_attr_list_complex tests/test_serialization.py::TestRuntimeSerialized::test_attr_list_simple tests/test_serialization.py::TestRuntimeSerialized::test_attr_none tests/test_serialization.py::TestRuntimeSerialized::test_attr_sequence tests/test_serialization.py::TestRuntimeSerialized::test_attr_str tests/test_serialization.py::TestRuntimeSerialized::test_empty_list tests/test_serialization.py::TestRuntimeSerialized::test_json_with_xml_map tests/test_serialization.py::TestRuntimeSerialized::test_key_type tests/test_serialization.py::TestRuntimeSerialized::test_long_as_type_object tests/test_serialization.py::TestRuntimeSerialized::test_model_validate tests/test_serialization.py::TestRuntimeSerialized::test_obj_serialize_none tests/test_serialization.py::TestRuntimeSerialized::test_obj_with_malformed_map tests/test_serialization.py::TestRuntimeSerialized::test_obj_with_mismatched_map tests/test_serialization.py::TestRuntimeSerialized::test_polymorphic_serialization tests/test_serialization.py::TestRuntimeSerialized::test_serialize_datetime tests/test_serialization.py::TestRuntimeSerialized::test_serialize_direct_model tests/test_serialization.py::TestRuntimeSerialized::test_serialize_empty_iter tests/test_serialization.py::TestRuntimeSerialized::test_serialize_from_dict_datetime tests/test_serialization.py::TestRuntimeSerialized::test_serialize_int_as_iter_with_div tests/test_serialization.py::TestRuntimeSerialized::test_serialize_json_obj tests/test_serialization.py::TestRuntimeSerialized::test_serialize_object tests/test_serialization.py::TestRuntimeSerialized::test_serialize_primitive_types tests/test_serialization.py::TestRuntimeSerialized::test_serialize_str_as_iter tests/test_serialization.py::TestRuntimeSerialized::test_validate tests/test_serialization.py::TestRuntimeSerialized::test_validation_flag tests/test_serialization.py::TestRuntimeDeserialized::test_additional_properties tests/test_serialization.py::TestRuntimeDeserialized::test_additional_properties_declared tests/test_serialization.py::TestRuntimeDeserialized::test_additional_properties_flattening tests/test_serialization.py::TestRuntimeDeserialized::test_additional_properties_not_configured tests/test_serialization.py::TestRuntimeDeserialized::test_array_deserialize tests/test_serialization.py::TestRuntimeDeserialized::test_attr_bool tests/test_serialization.py::TestRuntimeDeserialized::test_attr_enum tests/test_serialization.py::TestRuntimeDeserialized::test_attr_int tests/test_serialization.py::TestRuntimeDeserialized::test_attr_list_complex tests/test_serialization.py::TestRuntimeDeserialized::test_attr_list_in_list tests/test_serialization.py::TestRuntimeDeserialized::test_attr_list_simple tests/test_serialization.py::TestRuntimeDeserialized::test_attr_none tests/test_serialization.py::TestRuntimeDeserialized::test_attr_str tests/test_serialization.py::TestRuntimeDeserialized::test_basic_deserialization tests/test_serialization.py::TestRuntimeDeserialized::test_cls_method_deserialization tests/test_serialization.py::TestRuntimeDeserialized::test_deserialize_date tests/test_serialization.py::TestRuntimeDeserialized::test_deserialize_datetime tests/test_serialization.py::TestRuntimeDeserialized::test_deserialize_object tests/test_serialization.py::TestRuntimeDeserialized::test_deserialize_storage tests/test_serialization.py::TestRuntimeDeserialized::test_invalid_json tests/test_serialization.py::TestRuntimeDeserialized::test_long_as_type_object tests/test_serialization.py::TestRuntimeDeserialized::test_non_obj_deserialization tests/test_serialization.py::TestRuntimeDeserialized::test_obj_with_malformed_map tests/test_serialization.py::TestRuntimeDeserialized::test_obj_with_no_attr tests/test_serialization.py::TestRuntimeDeserialized::test_personalize_deserialization tests/test_serialization.py::TestRuntimeDeserialized::test_polymorphic_deserialization tests/test_serialization.py::TestRuntimeDeserialized::test_polymorphic_deserialization_with_escape tests/test_serialization.py::TestRuntimeDeserialized::test_polymorphic_missing_info tests/test_serialization.py::TestRuntimeDeserialized::test_robust_deserialization tests/test_serialization.py::TestModelInstanceEquality::test_model_instance_equality
msrest/exceptions.py
msrest/exceptions.py