[Python-Dev] Re: RFC on Callable Type Syntax

2021-10-15 Thread Pradeep Kumar Srinivasan
Thanks for the responses, everyone. Overall, it seems like there were no strong 
objections to the proposal.

I didn't hear much about Question 2, though: Should we propose features beyond 
present-day `Callable` in the same PEP or defer it to a future PEP?

In case that question got lost in the other details, feel free to respond here. 
If not, I'll take it there aren't strong opinions either way.



Some of my other takeaways:

+ Address the implications of the syntax changes for Python.
+ Address edge cases like trailing commas, `Concatenate` for `ParamSpec`, and 
runtime value of the expression.
+ Explicitly discuss the function-name-as-a-type proposal.

We will be drafting the PEP over the coming month.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZL3KPQCB7IBW2YFAUAGNQAV3EXGPBDTO/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] RFC on PEP 673: Self Type

2021-11-16 Thread Pradeep Kumar Srinivasan
This PEP [1] introduces a simple and intuitive way to annotate methods and 
classmethods that return an instance of their class. Such methods and 
classmethods occur quite frequently, but the existing way to annotate them 
correctly is quite arcane and error-prone. The PEP introduces a special type 
`Self` to represent the type of the `self` parameter, similar to the `this` 
type in TypeScript and the `Self` type in Rust. We have implementations for 
mypy and pyright. The PEP does not affect CPython directly except for the 
addition of one special form (Self) to typing.py [2]. 

Since we have reached consensus on the PEP in typing-sig [3], we wanted to get 
your comments and suggestions before submitting to the Steering Council.

Thanks,
Pradeep Kumar Srinivasan
James Hilton-Balfe

[1]: https://www.python.org/dev/peps/pep-0673/
[2]: Adding `Self` to typing_extensions.py: 
https://github.com/python/typing/pull/933
[3]: See the comments from typing-sig members on the Google doc: 
https://docs.google.com/document/d/1ujuSMXDmSIOJpiZyV7mvBEC8P-y55AgSzXcvhrZciuI/edit?usp=sharing
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/G4F3ZMCJRWWRSF7O34Z7RPYQQK7QPGB6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] RFC on PEP 675: Arbitrary Literal Strings

2022-02-07 Thread Pradeep Kumar Srinivasan
PEP 675 [1] introduces a supertype for precise literal string types, such as 
`Literal["foo"]`, called `LiteralString`.

The PEP allows libraries to distinguish the type of command strings from data. 
Powerful, command-executing libraries try to prevent security vulnerabilities 
by accepting arguments separately from the SQL query or shell command. However, 
these libraries have no way to prevent programmers from, say, using f-strings 
to embed arguments within the command string, which can allow malicious users 
to execute arbitrary commands (called "SQL/shell injection"). With this PEP, 
libraries can rely on type checkers to prevent such common, undesired uses.

Scala has a very similar concept that is used to prevent SQL injection at 
compile time. [5] We also discuss the drawbacks of alternative approaches, such 
as security linters, full taint analysis, and NewTypes [6].

Since we have reached consensus on the PEP in typing-sig [2], we wanted to get 
your comments and suggestions before submitting to the Steering Council. 

This PEP is mainly useful for type checking. There are no changes to Python 
syntax or runtime behavior.

Discussions:
+ typing-sig: [2]
+ BPO issue suggesting using this PEP to prevent vulnerabilities in loggers: [4]
+ Reddit thread on r/Python discussing this PEP: [3]

Thanks,
S Pradeep Kumar
Graham Bleaney

[1]: https://www.python.org/dev/peps/pep-0675/
[2]: 
https://mail.python.org/archives/list/typing-...@python.org/thread/VB74EHNM4RODDFM64NEEEBJQVAUAWIAW/
[3]: 
https://www.reddit.com/r/Python/comments/r71lzi/pep_675_arbitrary_literal_strings/
[4]: https://bugs.python.org/issue46200
[5]: https://www.python.org/dev/peps/pep-0675/#literal-string-types-in-scala
[6]: https://www.python.org/dev/peps/pep-0675/#rejected-alternatives
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/AXR3ZBEZF2UTBC2RFCASBTQB4ZYNQGET/
Code of Conduct: http://python.org/psf/codeofconduct/