Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Hints Syntax #73047

Closed
YoSTEALTH mannequin opened this issue Dec 3, 2016 · 2 comments
Closed

Type Hints Syntax #73047

YoSTEALTH mannequin opened this issue Dec 3, 2016 · 2 comments
Labels
type-feature A feature request or enhancement

Comments

@YoSTEALTH
Copy link
Mannequin

YoSTEALTH mannequin commented Dec 3, 2016

BPO 28861
Nosy @YoSTEALTH

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-12-04.01:40:01.006>
created_at = <Date 2016-12-03.20:48:45.049>
labels = ['type-feature']
title = 'Type Hints Syntax'
updated_at = <Date 2016-12-04.01:40:00.992>
user = 'https://github.com/YoSTEALTH'

bugs.python.org fields:

activity = <Date 2016-12-04.01:40:00.992>
actor = 'YoSTEALTH'
assignee = 'none'
closed = True
closed_date = <Date 2016-12-04.01:40:01.006>
closer = 'YoSTEALTH'
components = []
creation = <Date 2016-12-03.20:48:45.049>
creator = 'YoSTEALTH'
dependencies = []
files = []
hgrepos = []
issue_num = 28861
keywords = []
message_count = 2.0
messages = ['282304', '282313']
nosy_count = 1.0
nosy_names = ['YoSTEALTH']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue28861'
versions = []

@YoSTEALTH
Copy link
Mannequin Author

YoSTEALTH mannequin commented Dec 3, 2016

Type Hints Syntax
-----------------

Goal: Is to make it easy to read function/methods arguments, yet keep the new and cool Type Hints.

For example this is a code from one of my function. Its getting to that point of what the heck is going on here?

def find_replace(string: str, find: (str, dict, list, tuple, set), replace: (str, list, tuple, set)='') -> str:
    pass

I know it can be rewritten as:

T = (str, dict, list, tuple, set)
def find_replace(string: str, find: T, replace: T='') -> str:
    pass

But when you start using variable to represent another variables type... maybe we are losing the plot here!

What if we could have both? Readability and type reference, what if it could be written as:

def find_replace(string, find, replace):
    targ str, *(str, dict, list, tuple, set) -> str
    # code here ...

targ = type argument (like *args and **kwargs)

Calling a "targ" like we call "global" but to represent types.

Simple Examples:

def Redirect(url='', code=301):
    targ (str, int) -> None

Just think about it...

@YoSTEALTH YoSTEALTH mannequin added the type-feature A feature request or enhancement label Dec 3, 2016
@YoSTEALTH
Copy link
Mannequin Author

YoSTEALTH mannequin commented Dec 4, 2016

I was told to post this in python-ideas and also i totally missed the most important part (type aliases) in my example (rushed it)

@YoSTEALTH YoSTEALTH mannequin closed this as completed Dec 4, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants