{"action":"created","issue":{"url":"https://api.github.com/repos/nvbn/py-backwards/issues/48","repository_url":"https://api.github.com/repos/nvbn/py-backwards","labels_url":"https://api.github.com/repos/nvbn/py-backwards/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/nvbn/py-backwards/issues/48/comments","events_url":"https://api.github.com/repos/nvbn/py-backwards/issues/48/events","html_url":"https://github.com/nvbn/py-backwards/issues/48","id":356590000,"node_id":"MDU6SXNzdWUzNTY1OTAwMDA=","number":48,"title":"Error triggering on this function but why?","user":{"login":"Xparx","id":715716,"node_id":"MDQ6VXNlcjcxNTcxNg==","avatar_url":"https://avatars2.githubusercontent.com/u/715716?v=4","gravatar_id":"","url":"https://api.github.com/users/Xparx","html_url":"https://github.com/Xparx","followers_url":"https://api.github.com/users/Xparx/followers","following_url":"https://api.github.com/users/Xparx/following{/other_user}","gists_url":"https://api.github.com/users/Xparx/gists{/gist_id}","starred_url":"https://api.github.com/users/Xparx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xparx/subscriptions","organizations_url":"https://api.github.com/users/Xparx/orgs","repos_url":"https://api.github.com/users/Xparx/repos","events_url":"https://api.github.com/users/Xparx/events{/privacy}","received_events_url":"https://api.github.com/users/Xparx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-03T19:52:32Z","updated_at":"2018-09-03T20:08:15Z","closed_at":null,"author_association":"NONE","body":"The following code can't be converted from 3.6 to python 3.5 and the error seems to stem from something in py-backwards, I just can't figure out what.\r\nI tried it in the online demo and it blew up.\r\n\r\n```\r\ndef validate_spec(self, file: h5py.File) -> bool:\r\n        \"\"\"\r\n        Validate the LoomConnection object against the format specification.\r\n\r\n        Args:\r\n                file:                   h5py File object\r\n\r\n        Returns:\r\n                True if the file conforms to the specs, else False\r\n\r\n        Remarks:\r\n                Upon return, the instance attributes 'self.errors' and 'self.warnings' contain\r\n                lists of errors and warnings, and the 'self.summary' attribute contains a summary\r\n                of the file contents.\r\n        \"\"\"\r\n        matrix_types = [\"float16\", \"float32\", \"float64\", \"int8\", \"int16\", \"int32\", \"int64\", \"uint8\", \"uint16\", \"uint32\", \"uint64\"]\r\n        vertex_types = [\"int8\", \"int16\", \"int32\", \"int64\", \"uint8\", \"uint16\", \"uint32\", \"uint64\"]\r\n        weight_types = [\"float16\", \"float32\", \"float64\"]\r\n\r\n        def delay_print(text: str) -> None:\r\n                self.summary.append(text)\r\n\r\n        def dt(t: str) -> str:\r\n                if str(t).startswith(\"|S\"):\r\n                        return f\"string\"\r\n                return str(t)\r\n\r\n        width_ra = max([len(x) for x in (file[\"row_attrs\"].keys())])\r\n        width_ca = max([len(x) for x in (file[\"col_attrs\"].keys())])\r\n        width_globals = max([len(x) for x in file.attrs.keys()])\r\n        width_layers = 0\r\n        if \"layers\" in file and len(file[\"layers\"]) > 0:\r\n                width_layers = max([len(x) for x in file[\"layers\"].keys()])\r\n        width_layers = max(width_layers, len(\"Main matrix\"))\r\n        width = max(width_ca, width_ra, width_globals)\r\n\r\n        delay_print(\"Global attributes:\")\r\n        for key, value in file.attrs.items():\r\n                if type(value) is str:\r\n                        self.warnings.append(f\"Global attribute '{key}' has dtype string, which will be deprecated in future Loom versions\")\r\n                        delay_print(f\"{key: >{width}} string\")\r\n                else:\r\n                        delay_print(f\"{key: >{width}} {dt(file.attrs[key].dtype)}\")\r\n\r\n        return len(self.errors) == 0\r\n```\r\n\r\nIf I remove the following code it works,\r\n```\r\ndelay_print(\"Global attributes:\")\r\nfor key, value in file.attrs.items():\r\n    if type(value) is str:\r\n        self.warnings.append(f\"Global attribute '{key}' has dtype string, which will be deprecated in future Loom versions\")\r\n        delay_print(f\"{key: >{width}} string\")\r\n    else:\r\n        delay_print(f\"{key: >{width}} {dt(file.attrs[key].dtype)}\")\r\n```\r\nbit this peace breaks something. Without triggering a syntax error.\r\nThe code comes from this project and file: https://github.com/linnarsson-lab/loompy/blob/master/loompy/loom_validator.py\r\n\r\nWhat is going on here? "},"comment":{"url":"https://api.github.com/repos/nvbn/py-backwards/issues/comments/418186322","html_url":"https://github.com/nvbn/py-backwards/issues/48#issuecomment-418186322","issue_url":"https://api.github.com/repos/nvbn/py-backwards/issues/48","id":418186322,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODE4NjMyMg==","user":{"login":"Xparx","id":715716,"node_id":"MDQ6VXNlcjcxNTcxNg==","avatar_url":"https://avatars2.githubusercontent.com/u/715716?v=4","gravatar_id":"","url":"https://api.github.com/users/Xparx","html_url":"https://github.com/Xparx","followers_url":"https://api.github.com/users/Xparx/followers","following_url":"https://api.github.com/users/Xparx/following{/other_user}","gists_url":"https://api.github.com/users/Xparx/gists{/gist_id}","starred_url":"https://api.github.com/users/Xparx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xparx/subscriptions","organizations_url":"https://api.github.com/users/Xparx/orgs","repos_url":"https://api.github.com/users/Xparx/repos","events_url":"https://api.github.com/users/Xparx/events{/privacy}","received_events_url":"https://api.github.com/users/Xparx/received_events","type":"User","site_admin":false},"created_at":"2018-09-03T20:08:15Z","updated_at":"2018-09-03T20:08:15Z","author_association":"NONE","body":"To simplify this somewhat.\r\nThe error seems to trigger on a type of line formated as this:\r\n`f\"{key: >{width}} string\"`"}}
{"actor":{"display_login":"Xparx"}}