{"action":"created","issue":{"url":"https://api.github.com/repos/hhatto/autopep8/issues/200","labels_url":"https://api.github.com/repos/hhatto/autopep8/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/hhatto/autopep8/issues/200/comments","events_url":"https://api.github.com/repos/hhatto/autopep8/issues/200/events","html_url":"https://github.com/hhatto/autopep8/issues/200","id":64884842,"number":200,"title":"parse_args API when using autopep8 as a module","user":{"login":"hayd","id":1931852,"avatar_url":"https://avatars.githubusercontent.com/u/1931852?v=3","gravatar_id":"","url":"https://api.github.com/users/hayd","html_url":"https://github.com/hayd","followers_url":"https://api.github.com/users/hayd/followers","following_url":"https://api.github.com/users/hayd/following{/other_user}","gists_url":"https://api.github.com/users/hayd/gists{/gist_id}","starred_url":"https://api.github.com/users/hayd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hayd/subscriptions","organizations_url":"https://api.github.com/users/hayd/orgs","repos_url":"https://api.github.com/users/hayd/repos","events_url":"https://api.github.com/users/hayd/events{/privacy}","received_events_url":"https://api.github.com/users/hayd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-28T01:45:03Z","updated_at":"2015-03-28T02:14:56Z","closed_at":null,"body":"It often System Error when passing something that looks like it ought to work. The README advertises using autopep8 as a module so passing args seems a reasonable thing to do, yet it very fiddly atm.\r\n```\r\nIn [23]: parse_args('')\r\nusage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]\r\n                [--ignore-local-config] [-r] [-j n] [-p n] [-a]\r\n                [--experimental] [--exclude globs] [--list-fixes]\r\n                [--ignore errors] [--select errors] [--max-line-length n]\r\n                [--range line line] [--indent-size n]\r\n                [files [files ...]]\r\nautopep8: error: incorrect number of arguments\r\nAn exception has occurred, use %tb to see the full traceback.\r\n\r\nSystemExit: 2\r\n\r\nTo exit: use 'exit', 'quit', or Ctrl-D.\r\n\r\nIn [24]: parse_args([''])\r\nOut[24]: Namespace(aggressive=0, diff=False, exclude=[], experimental=False, files=[u''], global_config=u'/Users/andy/.config/pep8', ignore=set([u'E24']), ignore_local_config=False, in_place=False, indent_size=4, jobs=1, line_range=None, list_fixes=False, max_line_length=79, pep8_passes=-1, recursive=False, select=u'', verbose=0)\r\n\r\nIn [25]: parse_args(['--range 1 10'])\r\nOut[25]: Namespace(aggressive=0, diff=False, exclude=[], experimental=False, files=[u'--range 1 10'], global_config=u'/Users/andy/.config/pep8', ignore=set([u'E24']), ignore_local_config=False, in_place=False, indent_size=4, jobs=1, line_range=None, list_fixes=False, max_line_length=79, pep8_passes=-1, recursive=False, select=u'', verbose=0)\r\n```\r\nPerhaps the API could be improved by allowing a dict to be passed.\r\n\r\n    fix_code(code, options={\"line_range\": [1, 10]})\r\n    # equivalent to\r\n    fix_code(code, options=parse_args({\"line_range\": [1, 10]}))\r\n\r\nwhere\r\n\r\n    parse_args(arguments, apply_config=False):\r\n        if isistance(arguments, dict):\r\n            options = parse_args([''], apply_config=apply_config)\r\n            for k, v in arguments.values():\r\n                setattr(options, k, v)\r\n            return options\r\n        ...."},"comment":{"url":"https://api.github.com/repos/hhatto/autopep8/issues/comments/87145309","html_url":"https://github.com/hhatto/autopep8/issues/200#issuecomment-87145309","issue_url":"https://api.github.com/repos/hhatto/autopep8/issues/200","id":87145309,"user":{"login":"myint","id":1235108,"avatar_url":"https://avatars.githubusercontent.com/u/1235108?v=3","gravatar_id":"","url":"https://api.github.com/users/myint","html_url":"https://github.com/myint","followers_url":"https://api.github.com/users/myint/followers","following_url":"https://api.github.com/users/myint/following{/other_user}","gists_url":"https://api.github.com/users/myint/gists{/gist_id}","starred_url":"https://api.github.com/users/myint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myint/subscriptions","organizations_url":"https://api.github.com/users/myint/orgs","repos_url":"https://api.github.com/users/myint/repos","events_url":"https://api.github.com/users/myint/events{/privacy}","received_events_url":"https://api.github.com/users/myint/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T02:14:56Z","updated_at":"2015-03-28T02:14:56Z","body":"I think it makes sense to allow `fix_code()` to optionally take in a dictionary. (I never really liked the way it is now, but kept it for compatibility.) Another option is to create an module-level object with the default options that the user could override. That would avoid using strings, which is kind of nice."}}