KEMBAR78
Added stub for user module by ashwch · Pull Request #1454 · python/typeshed · GitHub
Skip to content

Conversation

@ashwch
Copy link
Contributor

@ashwch ashwch commented Jul 2, 2017

Related to: #1147

@JelleZijlstra
Copy link
Member

This seems like a bit of a special case, in that it's intended to include arbitrary user-specified code. I think we should add a module-level __getattr__ as agreed on in #5.



home: str
pythonrc: Union[bytes, Text]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it always bytes?

Copy link
Contributor Author

@ashwch ashwch Jul 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case yes, but it can return both in general.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in this case all the arguments are bytes, so the return will also be bytes.


home: str
pythonrc: Union[bytes, Text]
f: BinaryIO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not exist (it will only exist if ~/.pythonrc.py exists).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JelleZijlstra How do we deal with variables that may or may not exist?

Secondly is it okay if I include few more stubs in the same PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the module-level __getattr__ should suffice and we can just omit f.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please submit stubs for other modules as separate PRs.

@JelleZijlstra
Copy link
Member

To fix the test failure, you can add # type: ignore for now. I just submitted a PR to mypy (python/mypy#3647) to support module-level __getattr__ properly.

@JelleZijlstra JelleZijlstra merged commit 489696e into python:master Jul 2, 2017
@ashwch ashwch deleted the user-module branch July 3, 2017 04:00
rhysparry added a commit to rhysparry/typeshed that referenced this pull request Jul 3, 2017
* python/master:
  Added stub for toaiff module (python#1455)
  Added stub for user module (python#1454)
  Add more multiprocessing function stubs (python#1435)
  PyYaml: uncomment commented out imports and add missing classmethod decorators (python#1439)
  Allow `os.readlink` to accept path-like objects (python#1441)
  Support named attributes in `os.uname()` result (python#1445)
  Fix signature for slite3.fetchmany (python#1444)
  Add __name__ field to MethodType (python#1442)
  Add TypedDict total argument (python#1443)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants