Name | definitely-typed JSON |
Version |
0.2
JSON |
| download |
home_page | None |
Summary | Definitely typed. Type any object to any type as you wish. |
upload_time | 2024-08-16 11:07:39 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 AWeirdDev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
typing
definitely
type-hints
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# definitely
Typing tricks that make your type checker *a little* more quiet.
**Key features**:
- `definitely` – Type everything as you wish.
- `asyncily` – Run a function asynchronously.
- `asyncily_iterate` – Iterate through an iterator asynchronously.
- `reversely` – Reverse a dictionary.
```haskell
pip install definitely-typed
```
I should all be responsible about this, admittedly. Sorry guys.
## Methods
They just exist!
### <kbd>def</kbd> definitely
Definitely typed.
```python
person = "Charles"
# Transforms `person` into any type you desire
assert definitely(person, int)
reveal_type(person)
# ^^^^^^
# runtime: str
# typecheck: int
```
The runtime type **WILL NOT** change, yet when `TYPE_CHECKING`, the variable acts just like the desired type (in this case, `int`).
### <kbd>def</kbd> asyncily
Asynchronously run a function.
```python
# You can use this as a decorator like so:
@asyncily
def buy_stuff(item: str):
print("dad is going out!")
time.sleep(2 << 40)
print("came back with the %s!" % item)
await buy_stuff("milk")
# Or, you can use this as a "async function factory" like so:
def make(name: str):
return f"Made product: {name!r}"
amake = asyncily(make)
await amake("milk")
```
### <kbd>def</kbd> asyncily_iterate
Asynchronously iterate through an iterator.
```python
def get_resources():
yield from ["banana", "guava", "apple"]
async for resource in asyncily_iterate(get_resources()):
print("-", resource)
# Output:
# - banana
# - guava
# - apple
```
### <kbd>def</kbd> reversely
Reverse a dictionary.
```python
metadata = {"password": 1234, "total_users": 100_000}
reversed_metadata = reversely(metadata)
assert reversed_metadata == {1234: "password", 100_000: "users"}
reveal_type(reversed_metadata)
# ^^^^^^^^^^^^^^^^^
# runtime: dict[int, str]
# typecheck: dict[str, int]
```
***
(c) 2024 AWeirdDev, and other silly people
Raw data
{
"_id": null,
"home_page": null,
"name": "definitely-typed",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "typing, definitely, type-hints",
"author": null,
"author_email": "AWeirdDev <aweirdscratcher@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/6b/8e/6316b08fbc2b034a1dd2ceabad77eae91224973f49c57b6e3e1e06079992/definitely_typed-0.2.tar.gz",
"platform": null,
"description": "# definitely\r\nTyping tricks that make your type checker *a little* more quiet.\r\n\r\n**Key features**:\r\n- `definitely` \u2013 Type everything as you wish.\r\n- `asyncily` \u2013 Run a function asynchronously.\r\n- `asyncily_iterate` \u2013 Iterate through an iterator asynchronously.\r\n- `reversely` \u2013 Reverse a dictionary.\r\n\r\n```haskell\r\npip install definitely-typed\r\n```\r\n\r\nI should all be responsible about this, admittedly. Sorry guys.\r\n\r\n## Methods\r\nThey just exist!\r\n\r\n### <kbd>def</kbd> definitely\r\nDefinitely typed.\r\n\r\n```python\r\nperson = \"Charles\"\r\n\r\n# Transforms `person` into any type you desire\r\nassert definitely(person, int)\r\n\r\nreveal_type(person)\r\n# ^^^^^^\r\n# runtime: str\r\n# typecheck: int\r\n```\r\n\r\nThe runtime type **WILL NOT** change, yet when `TYPE_CHECKING`, the variable acts just like the desired type (in this case, `int`).\r\n\r\n### <kbd>def</kbd> asyncily\r\nAsynchronously run a function.\r\n\r\n```python\r\n# You can use this as a decorator like so:\r\n@asyncily\r\ndef buy_stuff(item: str):\r\n print(\"dad is going out!\")\r\n time.sleep(2 << 40)\r\n print(\"came back with the %s!\" % item)\r\n\r\nawait buy_stuff(\"milk\")\r\n\r\n# Or, you can use this as a \"async function factory\" like so:\r\ndef make(name: str):\r\n return f\"Made product: {name!r}\"\r\n\r\namake = asyncily(make)\r\nawait amake(\"milk\")\r\n```\r\n\r\n### <kbd>def</kbd> asyncily_iterate\r\nAsynchronously iterate through an iterator.\r\n\r\n```python\r\ndef get_resources():\r\n yield from [\"banana\", \"guava\", \"apple\"]\r\n\r\nasync for resource in asyncily_iterate(get_resources()):\r\n print(\"-\", resource)\r\n\r\n# Output:\r\n# - banana\r\n# - guava\r\n# - apple\r\n```\r\n\r\n### <kbd>def</kbd> reversely\r\nReverse a dictionary.\r\n\r\n```python\r\nmetadata = {\"password\": 1234, \"total_users\": 100_000}\r\nreversed_metadata = reversely(metadata)\r\n\r\nassert reversed_metadata == {1234: \"password\", 100_000: \"users\"}\r\n\r\nreveal_type(reversed_metadata)\r\n# ^^^^^^^^^^^^^^^^^\r\n# runtime: dict[int, str]\r\n# typecheck: dict[str, int]\r\n```\r\n\r\n***\r\n\r\n(c) 2024 AWeirdDev, and other silly people\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 AWeirdDev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Definitely typed. Type any object to any type as you wish.",
"version": "0.2",
"project_urls": {
"Bug Tracker": "https://github.com/AWeirdDev/definitely/issues",
"Source": "https://github.com/AWeirdDev/definitely"
},
"split_keywords": [
"typing",
" definitely",
" type-hints"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6b8e6316b08fbc2b034a1dd2ceabad77eae91224973f49c57b6e3e1e06079992",
"md5": "da8287f4ad71c03af62a500cd5584ad4",
"sha256": "a6970ff8ee56827119f4e50aa3891196c6a4f3f7a96fc6540faa5586432af21e"
},
"downloads": -1,
"filename": "definitely_typed-0.2.tar.gz",
"has_sig": false,
"md5_digest": "da8287f4ad71c03af62a500cd5584ad4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 4453,
"upload_time": "2024-08-16T11:07:39",
"upload_time_iso_8601": "2024-08-16T11:07:39.466439Z",
"url": "https://files.pythonhosted.org/packages/6b/8e/6316b08fbc2b034a1dd2ceabad77eae91224973f49c57b6e3e1e06079992/definitely_typed-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-16 11:07:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AWeirdDev",
"github_project": "definitely",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "definitely-typed"
}