Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-116126: Implement PEP 696#116129

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 56 commits intopython:mainfromJelleZijlstra:pep696v2
May 3, 2024
Merged
Changes from1 commit
Commits
Show all changes
56 commits
Select commitHold shift + click to select a range
e7ca092
gh-116126: Grammar changes for PEP 696
JelleZijlstraFeb 29, 2024
828679e
Fix test_ast
JelleZijlstraFeb 29, 2024
d3b472b
new tests
JelleZijlstraFeb 29, 2024
6e467ee
fix test_unparse
JelleZijlstraFeb 29, 2024
fa48580
possible solution
JelleZijlstraMar 1, 2024
49b077b
Can't use the name either
JelleZijlstraMar 1, 2024
5cfd5e2
blurb
JelleZijlstraMar 1, 2024
01b3270
should not have pushed that
JelleZijlstraMar 1, 2024
7a69204
maybe this will compile
JelleZijlstraMar 1, 2024
a265008
Feature version support
JelleZijlstraMar 1, 2024
0c28297
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 10, 2024
8aa5b27
default_ -> default_value
JelleZijlstraApr 10, 2024
bdd01bb
ast docs
JelleZijlstraApr 10, 2024
2c28b9a
more docs
JelleZijlstraApr 10, 2024
b0d467f
Fix typevarobject.c
JelleZijlstraApr 10, 2024
d7e91e2
default=<unrepresentable>
JelleZijlstraApr 10, 2024
35226b4
NoneType is immortal
JelleZijlstraApr 10, 2024
2e079ee
Runtime implementation
JelleZijlstraApr 10, 2024
e037052
What's New
JelleZijlstraApr 10, 2024
7b15f11
Document None/NoneType weirdness
JelleZijlstraApr 10, 2024
11bd102
fix doctest
JelleZijlstraApr 11, 2024
c54aeed
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 23, 2024
71a348b
Feedback from Alex
JelleZijlstraApr 23, 2024
900cd40
Partial work
JelleZijlstraApr 23, 2024
c13420b
Allow * in TypeVarTuple default
JelleZijlstraApr 23, 2024
8a08c62
Test and fix grammar
JelleZijlstraApr 23, 2024
613159f
Fix TypeVarTuple substitution
JelleZijlstraApr 23, 2024
4e0435e
Two more cases
JelleZijlstraApr 23, 2024
7d54ace
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 23, 2024
12581d8
Fix TypeVar substitution
JelleZijlstraApr 23, 2024
2b5a102
Fix ParamSpec
JelleZijlstraApr 23, 2024
a2c48c9
Prohibit default after TypeVarTuple
JelleZijlstraApr 23, 2024
29b9435
Wrap new syntax in run_code()
JelleZijlstraApr 23, 2024
326de17
Silence Ruff
JelleZijlstraApr 23, 2024
6f66775
Fix parameter markup
JelleZijlstraApr 23, 2024
7efa4ce
default_ -> default_value
JelleZijlstraApr 23, 2024
29ad843
Fix errors
JelleZijlstraApr 23, 2024
2c04c14
arguments, not parameters
JelleZijlstraApr 23, 2024
7d4f3fd
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 23, 2024
1a14367
Apply suggestions from code review
JelleZijlstraApr 23, 2024
5890d79
regen clinic
JelleZijlstraApr 23, 2024
19a7b48
variadic args for _unpack_args
JelleZijlstraApr 23, 2024
ef0616b
Update Lib/typing.py
JelleZijlstraApr 23, 2024
9d4e842
Update Doc/reference/executionmodel.rst
JelleZijlstraApr 23, 2024
2686b97
Roundtrip tests
JelleZijlstraApr 24, 2024
98d1dec
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 28, 2024
fbb6405
Fix doctest
JelleZijlstraApr 28, 2024
e0ccfeb
Add typing.NoDefault as the default for TypeVar's default
JelleZijlstraApr 28, 2024
15aaff9
Apply suggestions from code review
JelleZijlstraApr 28, 2024
86f5aed
Add .has_default() and update docs
JelleZijlstraApr 28, 2024
3e0c0fc
Apply suggestions from code review
JelleZijlstraApr 28, 2024
f5a3d4b
remove trailing space
JelleZijlstraApr 28, 2024
92ea108
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraApr 30, 2024
5f6fdfd
Ignore new C globals
JelleZijlstraApr 30, 2024
b3f053c
Merge remote-tracking branch 'upstream/main' into pep696v2
JelleZijlstraMay 3, 2024
8c3e0b4
Fix scoping key
JelleZijlstraMay 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
default_ -> default_value
  • Loading branch information
@JelleZijlstra
JelleZijlstra committedApr 23, 2024
commit7efa4ce5f274c38b0b86ab3ab48289883b10c897
108 changes: 54 additions & 54 deletionsObjects/typevarobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ typedef struct {
PyObject *evaluate_bound;
PyObject *constraints;
PyObject *evaluate_constraints;
PyObject *default_;
PyObject *default_value;
PyObject *evaluate_default;
bool covariant;
bool contravariant;
Expand All@@ -33,15 +33,15 @@ typedef struct {
typedef struct {
PyObject_HEAD
PyObject *name;
PyObject *default_;
PyObject *default_value;
PyObject *evaluate_default;
} typevartupleobject;

typedef struct {
PyObject_HEAD
PyObject *name;
PyObject *bound;
PyObject *default_;
PyObject *default_value;
PyObject *evaluate_default;
bool covariant;
bool contravariant;
Expand DownExpand Up@@ -206,7 +206,7 @@ typevar_dealloc(PyObject *self)
Py_XDECREF(tv->evaluate_bound);
Py_XDECREF(tv->constraints);
Py_XDECREF(tv->evaluate_constraints);
Py_XDECREF(tv->default_);
Py_XDECREF(tv->default_value);
Py_XDECREF(tv->evaluate_default);
PyObject_ClearManagedDict(self);
PyObject_ClearWeakRefs(self);
Expand All@@ -224,7 +224,7 @@ typevar_traverse(PyObject *self, visitproc visit, void *arg)
Py_VISIT(tv->evaluate_bound);
Py_VISIT(tv->constraints);
Py_VISIT(tv->evaluate_constraints);
Py_VISIT(tv->default_);
Py_VISIT(tv->default_value);
Py_VISIT(tv->evaluate_default);
PyObject_VisitManagedDict(self, visit, arg);
return 0;
Expand All@@ -237,7 +237,7 @@ typevar_clear(typevarobject *self)
Py_CLEAR(self->evaluate_bound);
Py_CLEAR(self->constraints);
Py_CLEAR(self->evaluate_constraints);
Py_CLEAR(self->default_);
Py_CLEAR(self->default_value);
Py_CLEAR(self->evaluate_default);
PyObject_ClearManagedDict((PyObject *)self);
return 0;
Expand DownExpand Up@@ -281,18 +281,18 @@ typevar_bound(typevarobject *self, void *Py_UNUSED(ignored))
static PyObject *
typevar_default(typevarobject *self, void *unused)
{
if (self->default_ != NULL) {
return Py_NewRef(self->default_);
if (self->default_value != NULL) {
return Py_NewRef(self->default_value);
}
if (self->evaluate_default == NULL) {
Py_RETURN_NONE;
}
PyObject *default_ = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
PyObject *default_value = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}
self->default_ = Py_XNewRef(default_);
returndefault_;
self->default_value = Py_XNewRef(default_value);
returndefault_value;
}

static PyObject *
Expand All@@ -319,7 +319,7 @@ static PyGetSetDef typevar_getset[] = {
static typevarobject *
typevar_alloc(PyObject *name, PyObject *bound, PyObject *evaluate_bound,
PyObject *constraints, PyObject *evaluate_constraints,
PyObject *default_,
PyObject *default_value,
bool covariant, bool contravariant, bool infer_variance,
PyObject *module)
{
Expand All@@ -336,7 +336,7 @@ typevar_alloc(PyObject *name, PyObject *bound, PyObject *evaluate_bound,
tv->evaluate_bound = Py_XNewRef(evaluate_bound);
tv->constraints = Py_XNewRef(constraints);
tv->evaluate_constraints = Py_XNewRef(evaluate_constraints);
tv->default_ = Py_XNewRef(default_);
tv->default_value = Py_XNewRef(default_value);
tv->evaluate_default = NULL;

tv->covariant = covariant;
Expand All@@ -361,7 +361,7 @@ typevar.__new__ as typevar_new
name: object(subclass_of="&PyUnicode_Type")
*constraints: object
bound: object = None
default asdefault_: object = NULL
default asdefault_value: object = NULL
covariant: bool = False
contravariant: bool = False
infer_variance: bool = False
Expand All@@ -371,7 +371,7 @@ Create a TypeVar.

static PyObject *
typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
PyObject *bound, PyObject *default_, int covariant,
PyObject *bound, PyObject *default_value, int covariant,
int contravariant, int infer_variance)
/*[clinic end generated code: output=74ee963663330604 input=2962ee79d92972fc]*/
{
Expand DownExpand Up@@ -417,13 +417,13 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
Py_XDECREF(bound);
return NULL;
}
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}

PyObject *tv = (PyObject *)typevar_alloc(name, bound, NULL,
constraints, NULL,
default_,
default_value,
covariant, contravariant,
infer_variance, module);
Py_XDECREF(bound);
Expand DownExpand Up@@ -844,7 +844,7 @@ paramspec_dealloc(PyObject *self)

Py_DECREF(ps->name);
Py_XDECREF(ps->bound);
Py_XDECREF(ps->default_);
Py_XDECREF(ps->default_value);
Py_XDECREF(ps->evaluate_default);
PyObject_ClearManagedDict(self);
PyObject_ClearWeakRefs(self);
Expand All@@ -859,7 +859,7 @@ paramspec_traverse(PyObject *self, visitproc visit, void *arg)
Py_VISIT(Py_TYPE(self));
paramspecobject *ps = (paramspecobject *)self;
Py_VISIT(ps->bound);
Py_VISIT(ps->default_);
Py_VISIT(ps->default_value);
Py_VISIT(ps->evaluate_default);
PyObject_VisitManagedDict(self, visit, arg);
return 0;
Expand All@@ -869,7 +869,7 @@ static int
paramspec_clear(paramspecobject *self)
{
Py_CLEAR(self->bound);
Py_CLEAR(self->default_);
Py_CLEAR(self->default_value);
Py_CLEAR(self->evaluate_default);
PyObject_ClearManagedDict((PyObject *)self);
return 0;
Expand DownExpand Up@@ -914,18 +914,18 @@ paramspec_kwargs(PyObject *self, void *unused)
static PyObject *
paramspec_default(paramspecobject *self, void *unused)
{
if (self->default_ != NULL) {
return Py_NewRef(self->default_);
if (self->default_value != NULL) {
return Py_NewRef(self->default_value);
}
if (self->evaluate_default == NULL) {
Py_RETURN_NONE;
}
PyObject *default_ = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
PyObject *default_value = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}
self->default_ = Py_XNewRef(default_);
returndefault_;
self->default_value = Py_XNewRef(default_value);
returndefault_value;
}

static PyGetSetDef paramspec_getset[] = {
Expand All@@ -936,7 +936,7 @@ static PyGetSetDef paramspec_getset[] = {
};

static paramspecobject *
paramspec_alloc(PyObject *name, PyObject *bound, PyObject *default_, bool covariant,
paramspec_alloc(PyObject *name, PyObject *bound, PyObject *default_value, bool covariant,
bool contravariant, bool infer_variance, PyObject *module)
{
PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.paramspec_type;
Expand All@@ -949,7 +949,7 @@ paramspec_alloc(PyObject *name, PyObject *bound, PyObject *default_, bool covari
ps->covariant = covariant;
ps->contravariant = contravariant;
ps->infer_variance = infer_variance;
ps->default_ = Py_XNewRef(default_);
ps->default_value = Py_XNewRef(default_value);
ps->evaluate_default = NULL;
_PyObject_GC_TRACK(ps);
if (module != NULL) {
Expand All@@ -968,7 +968,7 @@ paramspec.__new__ as paramspec_new
name: object(subclass_of="&PyUnicode_Type")
*
bound: object = None
default asdefault_: object = NULL
default asdefault_value: object = NULL
covariant: bool = False
contravariant: bool = False
infer_variance: bool = False
Expand All@@ -978,7 +978,7 @@ Create a ParamSpec object.

static PyObject *
paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
PyObject *default_, int covariant, int contravariant,
PyObject *default_value, int covariant, int contravariant,
int infer_variance)
/*[clinic end generated code: output=b6be5856624d7b5d input=5f16268ae6237a50]*/
{
Expand All@@ -1001,11 +1001,11 @@ paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
Py_XDECREF(bound);
return NULL;
}
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}
PyObject *ps = (PyObject *)paramspec_alloc(
name, bound,default_, covariant, contravariant, infer_variance, module);
name, bound,default_value, covariant, contravariant, infer_variance, module);
Py_XDECREF(bound);
Py_DECREF(module);
return ps;
Expand DownExpand Up@@ -1164,7 +1164,7 @@ typevartuple_dealloc(PyObject *self)
typevartupleobject *tvt = (typevartupleobject *)self;

Py_DECREF(tvt->name);
Py_XDECREF(tvt->default_);
Py_XDECREF(tvt->default_value);
Py_XDECREF(tvt->evaluate_default);
PyObject_ClearManagedDict(self);
PyObject_ClearWeakRefs(self);
Expand DownExpand Up@@ -1205,15 +1205,15 @@ static PyMemberDef typevartuple_members[] = {
};

static typevartupleobject *
typevartuple_alloc(PyObject *name, PyObject *module, PyObject *default_)
typevartuple_alloc(PyObject *name, PyObject *module, PyObject *default_value)
{
PyTypeObject *tp = _PyInterpreterState_GET()->cached_objects.typevartuple_type;
typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp);
if (tvt == NULL) {
return NULL;
}
tvt->name = Py_NewRef(name);
tvt->default_ = Py_XNewRef(default_);
tvt->default_value = Py_XNewRef(default_value);
tvt->evaluate_default = NULL;
_PyObject_GC_TRACK(tvt);
if (module != NULL) {
Expand All@@ -1231,23 +1231,23 @@ typevartuple.__new__

name: object(subclass_of="&PyUnicode_Type")
*
default asdefault_: object = NULL
default asdefault_value: object = NULL

Create a new TypeVarTuple with the given name.
[clinic start generated code]*/

static PyObject *
typevartuple_impl(PyTypeObject *type, PyObject *name, PyObject *default_)
typevartuple_impl(PyTypeObject *type, PyObject *name, PyObject *default_value)
/*[clinic end generated code: output=eb847fe0acd69560 input=b2f0ecf512371a75]*/
{
PyObject *module = caller();
if (module == NULL) {
return NULL;
}
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}
PyObject *result = (PyObject *)typevartuple_alloc(name, module,default_);
PyObject *result = (PyObject *)typevartuple_alloc(name, module,default_value);
Py_DECREF(module);
return result;
}
Expand DownExpand Up@@ -1312,7 +1312,7 @@ static int
typevartuple_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
Py_VISIT(((typevartupleobject *)self)->default_);
Py_VISIT(((typevartupleobject *)self)->default_value);
Py_VISIT(((typevartupleobject *)self)->evaluate_default);
PyObject_VisitManagedDict(self, visit, arg);
return 0;
Expand All@@ -1321,7 +1321,7 @@ typevartuple_traverse(PyObject *self, visitproc visit, void *arg)
static int
typevartuple_clear(PyObject *self)
{
Py_CLEAR(((typevartupleobject *)self)->default_);
Py_CLEAR(((typevartupleobject *)self)->default_value);
Py_CLEAR(((typevartupleobject *)self)->evaluate_default);
PyObject_ClearManagedDict(self);
return 0;
Expand All@@ -1330,18 +1330,18 @@ typevartuple_clear(PyObject *self)
static PyObject *
typevartuple_default(typevartupleobject *self, void *unused)
{
if (self->default_ != NULL) {
return Py_NewRef(self->default_);
if (self->default_value != NULL) {
return Py_NewRef(self->default_value);
}
if (self->evaluate_default == NULL) {
Py_RETURN_NONE;
}
PyObject *default_ = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_)) {
default_ = (PyObject *)Py_TYPE(default_);
PyObject *default_value = PyObject_CallNoArgs(self->evaluate_default);
if (Py_IsNone(default_value)) {
default_value = (PyObject *)Py_TYPE(default_value);
}
self->default_ = Py_XNewRef(default_);
returndefault_;
self->default_value = Py_XNewRef(default_value);
returndefault_value;
}

static PyGetSetDef typevartuple_getset[] = {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp