Skip to content

Coerce in a set validation doesn't lead to type coercion #400

@rawrgulmuffins

Description

@rawrgulmuffins

Issue Statement

When doing a coercion on a singleton or list the expected type casting is done. In the case of a set the original type is returned and no exception is raised.

Expectation

Either sets can't do coercions and a schema error is raised or sets correctly return a set with the modified types.

Steps to reproduction

from ipaddress import IPv4Address
from voluptuous import Coerce, Schema

test_schema = Schema(Coerce(IPv4Address))
test_schema('192.0.0.2')
# Returns IPv4Address('192.0.0.2')
test_schema = Schema([Coerce(IPv4Address)])
test_schema(['192.0.0.2'])
# Returns [IPv4Address('192.0.0.2')]
test_schema = Schema({Coerce(IPv4Address)})
test_schema({'192.0.0.2'})
# Returns {'192.0.0.2'}
>>>

Versions

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
Python==3.7.2
voluptuous==0.11.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions