{"action":"created","issue":{"url":"https://api.github.com/repos/schematics/schematics/issues/315","repository_url":"https://api.github.com/repos/schematics/schematics","labels_url":"https://api.github.com/repos/schematics/schematics/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/schematics/schematics/issues/315/comments","events_url":"https://api.github.com/repos/schematics/schematics/issues/315/events","html_url":"https://github.com/schematics/schematics/issues/315","id":93966839,"number":315,"title":"StringType() allows casting from int to str","user":{"login":"xihan","id":1108382,"avatar_url":"https://avatars.githubusercontent.com/u/1108382?v=3","gravatar_id":"","url":"https://api.github.com/users/xihan","html_url":"https://github.com/xihan","followers_url":"https://api.github.com/users/xihan/followers","following_url":"https://api.github.com/users/xihan/following{/other_user}","gists_url":"https://api.github.com/users/xihan/gists{/gist_id}","starred_url":"https://api.github.com/users/xihan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xihan/subscriptions","organizations_url":"https://api.github.com/users/xihan/orgs","repos_url":"https://api.github.com/users/xihan/repos","events_url":"https://api.github.com/users/xihan/events{/privacy}","received_events_url":"https://api.github.com/users/xihan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-07-09T06:22:27Z","updated_at":"2016-04-11T22:01:40Z","closed_at":null,"body":"Hi, \r\n\r\nI noticed that StringType defines allow_casts = (str, int).\r\nI wonder what the motivation is for this. I was quite surprised that\r\na StringType() field silently casts int input to str.\r\n\r\nI can always make a subclass that overrides the allow_casts class variable though.\r\n\r\nThanks for your help!"},"comment":{"url":"https://api.github.com/repos/schematics/schematics/issues/comments/208580750","html_url":"https://github.com/schematics/schematics/issues/315#issuecomment-208580750","issue_url":"https://api.github.com/repos/schematics/schematics/issues/315","id":208580750,"user":{"login":"lkraider","id":52256,"avatar_url":"https://avatars.githubusercontent.com/u/52256?v=3","gravatar_id":"","url":"https://api.github.com/users/lkraider","html_url":"https://github.com/lkraider","followers_url":"https://api.github.com/users/lkraider/followers","following_url":"https://api.github.com/users/lkraider/following{/other_user}","gists_url":"https://api.github.com/users/lkraider/gists{/gist_id}","starred_url":"https://api.github.com/users/lkraider/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkraider/subscriptions","organizations_url":"https://api.github.com/users/lkraider/orgs","repos_url":"https://api.github.com/users/lkraider/repos","events_url":"https://api.github.com/users/lkraider/events{/privacy}","received_events_url":"https://api.github.com/users/lkraider/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T22:01:40Z","updated_at":"2016-04-11T22:01:40Z","body":"Is the issue about (1) the specific cases where `to_native -> String` are reasonable or about (2) the general case of only type-checking the input (and raising if `type(input) != str`)?\r\n\r\nFor (1), the following line could be removed:\r\nhttps://github.com/schematics/schematics/blob/879b7701e12cafa1f94b55cd6a645f657cd38134/schematics/types/base.py#L386\r\n\r\nFor (2), while applying the same solution above would resolve for the String type, I would propose to split the type test out of the `to_native` function, so that all types would basically refactor the `isinstance` checks out, enabling strict input type-checking for all types.\r\n"}}