Skip to content

Commit 85c0f50

Browse files
committed
Add type annotations
1 parent 7b392bd commit 85c0f50

File tree

17 files changed

+378
-248
lines changed

17 files changed

+378
-248
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
include_package_data=True,
3333
package_data={"": ["cacerts.txt", "cacert.pem"]},
3434
zip_safe=False,
35-
python_requires=">=3.7.0",
35+
python_requires=">=3.9.0",
3636
classifiers=[
3737
"Development Status :: 5 - Production/Stable",
3838
"Intended Audience :: Developers",

shotgun_api3/lib/httplib2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
from .. import six
23

34
# Define all here to keep linters happy. It should be overwritten by the code

shotgun_api3/lib/httplib2/auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import base64
23
import re
34

shotgun_api3/lib/httplib2/certs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
"""Utilities for certificate management."""
23

34
import os

shotgun_api3/lib/httplib2/iri2uri.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# type: ignore
23
"""Converts an IRI to a URI."""
34

45
__author__ = "Joe Gregorio (joe@bitworking.org)"

shotgun_api3/lib/httplib2/python3/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# type: ignore
23
"""Small, fast HTTP client library for Python."""
34

45
__author__ = "Joe Gregorio (joe@bitworking.org)"

shotgun_api3/lib/httplib2/python3/auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import base64
23
import re
34

shotgun_api3/lib/httplib2/python3/certs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
"""Utilities for certificate management."""
23

34
import os

shotgun_api3/lib/httplib2/python3/iri2uri.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# type: ignore
23
"""Converts an IRI to a URI."""
34

45
__author__ = "Joe Gregorio (joe@bitworking.org)"

shotgun_api3/lib/mimetypes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
a patched version of the native mimetypes module and is used only in Python
2727
versions 2.7.0 - 2.7.9, which included a broken version of the mimetypes module.
2828
"""
29+
from __future__ import print_function
2930

3031
import os
3132
import sys
@@ -568,14 +569,14 @@ def _default_mime_types():
568569
"""
569570

570571
def usage(code, msg=''):
571-
print USAGE
572-
if msg: print msg
572+
print(USAGE)
573+
if msg: print(msg)
573574
sys.exit(code)
574575

575576
try:
576577
opts, args = getopt.getopt(sys.argv[1:], 'hle',
577578
['help', 'lenient', 'extension'])
578-
except getopt.error, msg:
579+
except getopt.error as msg:
579580
usage(1, msg)
580581

581582
strict = 1
@@ -590,9 +591,9 @@ def usage(code, msg=''):
590591
for gtype in args:
591592
if extension:
592593
guess = guess_extension(gtype, strict)
593-
if not guess: print "I don't know anything about type", gtype
594-
else: print guess
594+
if not guess: print("I don't know anything about type", gtype)
595+
else: print(guess)
595596
else:
596597
guess, encoding = guess_type(gtype, strict)
597-
if not guess: print "I don't know anything about type", gtype
598-
else: print 'type:', guess, 'encoding:', encoding
598+
if not guess: print("I don't know anything about type", gtype)
599+
else: print('type:', guess, 'encoding:', encoding)

shotgun_api3/lib/mockgun/mockgun.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
from ...shotgun import _Config
121121
from .errors import MockgunError
122122
from .schema import SchemaFactory
123+
from typing import Any
123124

124125
# ----------------------------------------------------------------------------
125126
# Version
@@ -581,7 +582,7 @@ def _get_new_row(self, entity_type):
581582
row[field] = default_value
582583
return row
583584

584-
def _compare(self, field_type, lval, operator, rval):
585+
def _compare(self, field_type: str, lval: Any, operator: str, rval: Any) -> bool:
585586
"""
586587
Compares a field using the operator and value provide by the filter.
587588
@@ -798,7 +799,7 @@ def _row_matches_filter(self, entity_type, row, sg_filter, retired_only):
798799

799800
return self._compare(field_type, lval, operator, rval)
800801

801-
def _rearrange_filters(self, filters):
802+
def _rearrange_filters(self, filters: list) -> None:
802803
"""
803804
Modifies the filter syntax to turn it into a list of three items regardless
804805
of the actual filter. Most of the filters are list of three elements, so this doesn't change much.

shotgun_api3/lib/mockgun/schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
"""
23
-----------------------------------------------------------------------------
34
Copyright (c) 2009-2017, Shotgun Software Inc
@@ -47,7 +48,7 @@ class SchemaFactory(object):
4748
_schema_cache_path = None
4849

4950
@classmethod
50-
def get_schemas(cls, schema_path, schema_entity_path):
51+
def get_schemas(cls, schema_path: str, schema_entity_path: str) -> tuple:
5152
"""
5253
Retrieves the schemas from disk.
5354

shotgun_api3/lib/pyparsing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2323
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2424
#
25+
# type: ignore
2526

2627
__doc__ = \
2728
"""

shotgun_api3/lib/sgsix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
ShotgunSSLError = SSLHandshakeError
5959

6060

61-
def normalize_platform(platform, python2=True):
61+
def normalize_platform(platform: str, python2: bool = True) -> str:
6262
"""
6363
Normalize the return of sys.platform between Python 2 and 3.
6464

shotgun_api3/lib/sgutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"""
3030

3131

32-
def ensure_binary(s, encoding='utf-8', errors='strict'):
32+
def ensure_binary(s, encoding='utf-8', errors='strict') -> bytes:
3333
"""
3434
Coerce **s** to bytes.
3535
@@ -44,7 +44,7 @@ def ensure_binary(s, encoding='utf-8', errors='strict'):
4444
raise TypeError(f"not expecting type '{type(s)}'")
4545

4646

47-
def ensure_str(s, encoding='utf-8', errors='strict'):
47+
def ensure_str(s, encoding='utf-8', errors='strict') -> str:
4848
"""Coerce *s* to `str`.
4949
5050
- `str` -> `str`

shotgun_api3/lib/six.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
20+
# type: ignore
2021

2122
"""Utilities for writing code that runs on Python 2 and 3"""
2223

0 commit comments

Comments
 (0)