Skip to content

Commit cf7e8db

Browse files
committed
Add type annotations
1 parent 7b392bd commit cf7e8db

File tree

7 files changed

+331
-228
lines changed

7 files changed

+331
-228
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/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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SchemaFactory(object):
4747
_schema_cache_path = None
4848

4949
@classmethod
50-
def get_schemas(cls, schema_path, schema_entity_path):
50+
def get_schemas(cls, schema_path: str, schema_entity_path: str) -> tuple:
5151
"""
5252
Retrieves the schemas from disk.
5353

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`

0 commit comments

Comments
 (0)