mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Manual implementation of typing of last parameters
This commit is contained in:
@@ -182,7 +182,7 @@
|
||||
"createElement": {
|
||||
"mandatoryParameters": [
|
||||
{ "name": "public", "type": "bool" },
|
||||
{ "name": "files", "type": "@todo" }
|
||||
{ "name": "files", "type": "dict:string-InputFileContent" }
|
||||
],
|
||||
"optionalParameters": [
|
||||
{ "name": "description", "type": "string" }
|
||||
@@ -422,7 +422,7 @@
|
||||
"edit": {
|
||||
"optionalParameters": [
|
||||
{ "name": "description", "type": "string" },
|
||||
{ "name": "files", "type": "@todo" }
|
||||
{ "name": "files", "type": "dict:string-InputFileContent" }
|
||||
]
|
||||
},
|
||||
"delete": true,
|
||||
@@ -934,7 +934,7 @@
|
||||
"createElement": {
|
||||
"mandatoryParameters": [
|
||||
{ "name": "public", "type": "bool" },
|
||||
{ "name": "files", "type": "@todo" }
|
||||
{ "name": "files", "type": "dict:string-InputFileContent" }
|
||||
],
|
||||
"optionalParameters": [
|
||||
{ "name": "description", "type": "string" }
|
||||
@@ -1463,8 +1463,8 @@
|
||||
{ "name": "parents", "type": "list:GitCommit" }
|
||||
],
|
||||
"optionalParameters": [
|
||||
{ "name": "author", "type": "@todo" },
|
||||
{ "name": "committer", "type": "@todo" }
|
||||
{ "name": "author", "type": "InputGitAuthor" },
|
||||
{ "name": "committer", "type": "InputGitAuthor" }
|
||||
]
|
||||
},
|
||||
"url": [
|
||||
@@ -1510,7 +1510,7 @@
|
||||
{ "name": "type", "type": "string" }
|
||||
],
|
||||
"optionalParameters": [
|
||||
{ "name": "tagger", "type": "@todo" }
|
||||
{ "name": "tagger", "type": "InputGitAuthor" }
|
||||
]
|
||||
},
|
||||
"getElement": {
|
||||
@@ -1527,7 +1527,7 @@
|
||||
"type": "GitTree",
|
||||
"createElement": {
|
||||
"mandatoryParameters": [
|
||||
{ "name": "tree", "type": "@todo" }
|
||||
{ "name": "tree", "type": "list:InputGitTreeElement" }
|
||||
],
|
||||
"optionalParameters": [
|
||||
{ "name": "base_tree", "type": "string" }
|
||||
|
||||
@@ -1205,8 +1205,9 @@
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"key_name": "string",
|
||||
"cardinality": "dict",
|
||||
"name": "InputFileContent"
|
||||
},
|
||||
"name": "files"
|
||||
}
|
||||
@@ -2585,8 +2586,9 @@
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"key_name": "string",
|
||||
"cardinality": "dict",
|
||||
"name": "InputFileContent"
|
||||
},
|
||||
"name": "files"
|
||||
}
|
||||
@@ -5331,8 +5333,9 @@
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"key_name": "string",
|
||||
"cardinality": "dict",
|
||||
"name": "InputFileContent"
|
||||
},
|
||||
"name": "files"
|
||||
}
|
||||
@@ -8453,7 +8456,7 @@
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"name": "InputGitAuthor"
|
||||
},
|
||||
"name": "author"
|
||||
},
|
||||
@@ -8461,7 +8464,7 @@
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"name": "InputGitAuthor"
|
||||
},
|
||||
"name": "committer"
|
||||
}
|
||||
@@ -8707,7 +8710,7 @@
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"name": "InputGitAuthor"
|
||||
},
|
||||
"name": "tagger"
|
||||
}
|
||||
@@ -8774,8 +8777,8 @@
|
||||
{
|
||||
"type": {
|
||||
"simple": false,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
"cardinality": "list",
|
||||
"name": "InputGitTreeElement"
|
||||
},
|
||||
"name": "tree"
|
||||
}
|
||||
|
||||
+10
-5
@@ -19,20 +19,25 @@ description = json.load( open( os.path.join( os.path.dirname( __file__ ), "JsonD
|
||||
|
||||
for class_ in description[ "classes" ]:
|
||||
dependencies = set()
|
||||
|
||||
class_[ "needsPaginatedList" ] = False
|
||||
class_[ "needsDefaultValue" ] = False
|
||||
|
||||
for method in class_[ "methods" ]:
|
||||
if method[ "type" ][ "cardinality" ] == "list":
|
||||
class_[ "needsPaginatedList" ] = True
|
||||
if len( method[ "optionalParameters" ] ) != 0:
|
||||
class_[ "needsDefaultValue" ] = True
|
||||
if not method[ "type" ][ "simple" ]:
|
||||
dependencies.add( method[ "type" ][ "name" ] )
|
||||
for parameter in itertools.chain( method[ "mandatoryParameters" ], method[ "optionalParameters" ] ):
|
||||
if not parameter[ "type" ][ "simple" ]:
|
||||
dependencies.add( parameter[ "type" ][ "name" ] )
|
||||
|
||||
for attribute in class_[ "attributes" ]:
|
||||
if not attribute[ "type" ][ "simple" ]:
|
||||
dependencies.add( attribute[ "type" ][ "name" ] )
|
||||
|
||||
for thing in itertools.chain( class_[ "methods" ], class_[ "attributes" ] ):
|
||||
if not thing[ "type" ][ "simple" ]:
|
||||
dependencies.add( thing[ "type" ][ "name" ] )
|
||||
class_[ "dependencies" ] = list( dependencies )
|
||||
|
||||
class_[ "needsUrllib" ] = class_[ "name" ] in [ "Label", "Repository" ]
|
||||
|
||||
githubObjectTemplate = django.template.loader.get_template( "GithubObject.py" )
|
||||
|
||||
@@ -12,14 +12,12 @@
|
||||
def _useAttributes( self, attributes ):
|
||||
{% for attribute in class.attributes|dictsort:"name" %}
|
||||
|
||||
{% if attribute.type.name != "@todo" %}
|
||||
{% with simple_or_complex=attribute.type.simple|yesno:"simple,complex_as_dict" %}
|
||||
{% with simple_or_complex=attribute.type.simple|yesno:"simple,complex_as_dict" %}
|
||||
if "{{ attribute.name }}" in attributes: # pragma no branch
|
||||
{% with template_name="GithubObject.IsInstance."|add:attribute.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:attribute.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert attributes[ "{{ attribute.name }}" ] is None or {% include template_name with variable="attributes[ \""|add:attribute.name|add:"\" ]"|safe type=attribute.type only %}, attributes[ "{{ attribute.name }}" ]
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
{% with simple_or_complex=attribute.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.AttributeValue."|add:simple_or_complex|add:".py" %}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
all( {% include "GithubObject.IsInstance.py" with variable="element" type=type.name|add:"."|add:type.name only %} for element in {{ variable }}.itervalues() )
|
||||
@@ -1,21 +1,17 @@
|
||||
{% for parameter in method.mandatoryParameters %}
|
||||
{% if parameter.type.name != "@todo" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert {% include template_name with variable=parameter.name type=parameter.type only %}, {{ parameter.name }}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
{% for parameter in method.optionalParameters %}
|
||||
{% if parameter.type.name != "@todo" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
{% with simple_or_complex=parameter.type.simple|yesno:"simple,complex" %}
|
||||
{% with template_name="GithubObject.IsInstance."|add:parameter.type.cardinality|add:"."|add:simple_or_complex|add:".py" %}
|
||||
assert {{ parameter.name }} is GithubObject.NotSet or {% include template_name with variable=parameter.name type=parameter.type only %}, {{ parameter.name }}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
{% if method.variadicParameter %}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% if type.name != "void" and type.name != "@todo" %}: {% if type.cardinality == "list" %}list of {% endif %}{% if type.cardinality == "dict" %}dict of {{ type.key_name }} to {% endif %}{% if not type.simple %}`{% endif %}{{ type.name }}{% if not type.simple %}`{% endif %}{% endif %}
|
||||
{% if type.name != "void" %}: {% if type.cardinality == "list" %}list of {% endif %}{% if type.cardinality == "dict" %}dict of {{ type.key_name }} to {% endif %}{% if not type.simple %}`{% endif %}{{ type.name }}{% if not type.simple %}`{% endif %}{% endif %}
|
||||
Reference in New Issue
Block a user