{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/traitlets/issues/108","labels_url":"https://api.github.com/repos/ipython/traitlets/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/ipython/traitlets/issues/108/comments","events_url":"https://api.github.com/repos/ipython/traitlets/issues/108/events","html_url":"https://github.com/ipython/traitlets/pull/108","id":111539545,"number":108,"title":"Default Decorator and Generate All Default Values \"On-Get\"","user":{"login":"rmorshea","id":4041990,"avatar_url":"https://avatars.githubusercontent.com/u/4041990?v=3","gravatar_id":"","url":"https://api.github.com/users/rmorshea","html_url":"https://github.com/rmorshea","followers_url":"https://api.github.com/users/rmorshea/followers","following_url":"https://api.github.com/users/rmorshea/following{/other_user}","gists_url":"https://api.github.com/users/rmorshea/gists{/gist_id}","starred_url":"https://api.github.com/users/rmorshea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmorshea/subscriptions","organizations_url":"https://api.github.com/users/rmorshea/orgs","repos_url":"https://api.github.com/users/rmorshea/repos","events_url":"https://api.github.com/users/rmorshea/events{/privacy}","received_events_url":"https://api.github.com/users/rmorshea/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-15T03:41:15Z","updated_at":"2015-11-06T00:39:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ipython/traitlets/pulls/108","html_url":"https://github.com/ipython/traitlets/pull/108","diff_url":"https://github.com/ipython/traitlets/pull/108.diff","patch_url":"https://github.com/ipython/traitlets/pull/108.patch"},"body":"New implementation of default decorators as compared to #76. To accomplish this, the logic for creating default values was consolidated into `TraitType.get` meaning that invalid defaults will only be caught, and valid ones will only be set, in the `HasTraits` instance when there's an attempt to access the value.\r\n\r\n```python\r\nclass A(HasTraits):\r\n    i = Int('bad default')\r\n\r\na = A() # no longer fails when instance is created\r\na.i # instead fails when trying to access the value\r\n```\r\n\r\nbrief default decorator example\r\n\r\n```python\r\nclass A(HasTraits):\r\n    i = Int()\r\n    \r\n    @default('x')\r\n    def _x_default(self):\r\n        return 1\r\n\r\nA().i\r\n# result : `1`\r\n```\r\n\r\ncloses #76, closes #89 "},"comment":{"url":"https://api.github.com/repos/ipython/traitlets/issues/comments/154247328","html_url":"https://github.com/ipython/traitlets/pull/108#issuecomment-154247328","issue_url":"https://api.github.com/repos/ipython/traitlets/issues/108","id":154247328,"user":{"login":"SylvainCorlay","id":2397974,"avatar_url":"https://avatars.githubusercontent.com/u/2397974?v=3","gravatar_id":"","url":"https://api.github.com/users/SylvainCorlay","html_url":"https://github.com/SylvainCorlay","followers_url":"https://api.github.com/users/SylvainCorlay/followers","following_url":"https://api.github.com/users/SylvainCorlay/following{/other_user}","gists_url":"https://api.github.com/users/SylvainCorlay/gists{/gist_id}","starred_url":"https://api.github.com/users/SylvainCorlay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SylvainCorlay/subscriptions","organizations_url":"https://api.github.com/users/SylvainCorlay/orgs","repos_url":"https://api.github.com/users/SylvainCorlay/repos","events_url":"https://api.github.com/users/SylvainCorlay/events{/privacy}","received_events_url":"https://api.github.com/users/SylvainCorlay/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T00:39:08Z","updated_at":"2015-11-06T00:39:08Z","body":"Closing. #114 added the default decorator. "}}