@@ -257,7 +257,6 @@ class Person(Model):
257
257
import inspect
258
258
import json
259
259
import pickle
260
- import six
261
260
import zlib
262
261
263
262
import pytz
@@ -1069,7 +1068,7 @@ def _verify_name(name):
1069
1068
TypeError: If the ``name`` is not a string.
1070
1069
ValueError: If the name contains a ``.``.
1071
1070
"""
1072
- if not isinstance (name , six . string_types ):
1071
+ if not isinstance (name , str ):
1073
1072
raise TypeError ("Name {!r} is not a string" .format (name ))
1074
1073
1075
1074
if "." in name :
@@ -2102,7 +2101,7 @@ def _legacy_db_get_value(v, p):
2102
2101
# If this passes, don't return unicode.
2103
2102
except UnicodeDecodeError :
2104
2103
try :
2105
- sval = six . text_type (sval .decode ("utf-8" ))
2104
+ sval = str (sval .decode ("utf-8" ))
2106
2105
except UnicodeDecodeError :
2107
2106
pass
2108
2107
return sval
@@ -2435,7 +2434,7 @@ def _validate(self, value):
2435
2434
.BadValueError: If ``value`` is not an :class:`int` or convertible
2436
2435
to one.
2437
2436
"""
2438
- if not isinstance (value , six . integer_types ):
2437
+ if not isinstance (value , int ):
2439
2438
raise exceptions .BadValueError (
2440
2439
"In field {}, expected integer, got {!r}" .format (self ._name , value )
2441
2440
)
@@ -2467,14 +2466,14 @@ def _validate(self, value):
2467
2466
.BadValueError: If ``value`` is not a :class:`float` or convertible
2468
2467
to one.
2469
2468
"""
2470
- if not isinstance (value , six . integer_types + (float ,)):
2469
+ if not isinstance (value , (float , int )):
2471
2470
raise exceptions .BadValueError (
2472
2471
"In field {}, expected float, got {!r}" .format (self ._name , value )
2473
2472
)
2474
2473
return float (value )
2475
2474
2476
2475
2477
- class _CompressedValue (six . binary_type ):
2476
+ class _CompressedValue (bytes ):
2478
2477
"""A marker object wrapping compressed values.
2479
2478
2480
2479
Args:
@@ -2784,7 +2783,7 @@ def _validate(self, value):
2784
2783
.BadValueError: If the current property is indexed but the UTF-8
2785
2784
encoded value exceeds the maximum length (1500 bytes).
2786
2785
"""
2787
- if not isinstance (value , six . text_type ):
2786
+ if not isinstance (value , str ):
2788
2787
# In Python 2.7, bytes is a synonym for str
2789
2788
if isinstance (value , bytes ):
2790
2789
try :
@@ -2811,7 +2810,7 @@ def _to_base_type(self, value):
2811
2810
:class:`str`, this will return the UTF-8 encoded bytes for it.
2812
2811
Otherwise, it will return :data:`None`.
2813
2812
"""
2814
- if isinstance (value , six . text_type ):
2813
+ if isinstance (value , str ):
2815
2814
return value .encode ("utf-8" )
2816
2815
2817
2816
def _from_base_type (self , value ):
@@ -2946,7 +2945,7 @@ def _validate(self, value):
2946
2945
.BadValueError: If the current property is indexed but the UTF-8
2947
2946
encoded value exceeds the maximum length (1500 bytes).
2948
2947
"""
2949
- if isinstance (value , six . binary_type ):
2948
+ if isinstance (value , bytes ):
2950
2949
try :
2951
2950
encoded_length = len (value )
2952
2951
value = value .decode ("utf-8" )
@@ -2956,7 +2955,7 @@ def _validate(self, value):
2956
2955
self ._name , value
2957
2956
)
2958
2957
)
2959
- elif isinstance (value , six . string_types ):
2958
+ elif isinstance (value , str ):
2960
2959
encoded_length = len (value .encode ("utf-8" ))
2961
2960
else :
2962
2961
raise exceptions .BadValueError ("Expected string, got {!r}" .format (value ))
@@ -2978,7 +2977,7 @@ def _to_base_type(self, value):
2978
2977
:class:`bytes`, this will return the UTF-8 decoded ``str`` for it.
2979
2978
Otherwise, it will return :data:`None`.
2980
2979
"""
2981
- if isinstance (value , six . binary_type ):
2980
+ if isinstance (value , bytes ):
2982
2981
return value .decode ("utf-8" )
2983
2982
2984
2983
def _from_base_type (self , value ):
@@ -3001,7 +3000,7 @@ def _from_base_type(self, value):
3001
3000
:class:`str` corresponding to it. Otherwise, it will return
3002
3001
:data:`None`.
3003
3002
"""
3004
- if isinstance (value , six . binary_type ):
3003
+ if isinstance (value , bytes ):
3005
3004
try :
3006
3005
return value .decode ("utf-8" )
3007
3006
except UnicodeError :
@@ -3209,7 +3208,7 @@ def _from_base_type(self, value):
3209
3208
"""
3210
3209
# We write and retrieve `bytes` normally, but for some reason get back
3211
3210
# `str` from a projection query.
3212
- if not isinstance (value , six . text_type ):
3211
+ if not isinstance (value , str ):
3213
3212
value = value .decode ("ascii" )
3214
3213
return json .loads (value )
3215
3214
@@ -3510,14 +3509,14 @@ def _to_base_type(self, value):
3510
3509
user_entity = ds_entity_module .Entity ()
3511
3510
3512
3511
# Set required fields.
3513
- user_entity ["email" ] = six . ensure_text (value .email ())
3512
+ user_entity ["email" ] = str (value .email ())
3514
3513
user_entity .exclude_from_indexes .add ("email" )
3515
- user_entity ["auth_domain" ] = six . ensure_text (value .auth_domain ())
3514
+ user_entity ["auth_domain" ] = str (value .auth_domain ())
3516
3515
user_entity .exclude_from_indexes .add ("auth_domain" )
3517
3516
# Set optional field.
3518
3517
user_id = value .user_id ()
3519
3518
if user_id :
3520
- user_entity ["user_id" ] = six . ensure_text (user_id )
3519
+ user_entity ["user_id" ] = str (user_id )
3521
3520
user_entity .exclude_from_indexes .add ("user_id" )
3522
3521
3523
3522
return user_entity
@@ -3612,7 +3611,7 @@ def _handle_positional(wrapped):
3612
3611
@functools .wraps (wrapped )
3613
3612
def wrapper (self , * args , ** kwargs ):
3614
3613
for arg in args :
3615
- if isinstance (arg , six . string_types ):
3614
+ if isinstance (arg , str ):
3616
3615
if "name" in kwargs :
3617
3616
raise TypeError ("You can only specify name once" )
3618
3617
@@ -3651,7 +3650,7 @@ def __init__(
3651
3650
kind = kind ._get_kind ()
3652
3651
3653
3652
else :
3654
- if kind is not None and not isinstance (kind , six . string_types ):
3653
+ if kind is not None and not isinstance (kind , str ):
3655
3654
raise TypeError ("Kind must be a Model class or a string" )
3656
3655
3657
3656
super (KeyProperty , self ).__init__ (
@@ -3933,7 +3932,7 @@ def _from_base_type(self, value):
3933
3932
returns the value without ``tzinfo`` or ``None`` if value did
3934
3933
not have ``tzinfo`` set.
3935
3934
"""
3936
- if isinstance (value , six . integer_types ):
3935
+ if isinstance (value , int ):
3937
3936
# Projection query, value is integer nanoseconds
3938
3937
seconds = value / 1e6
3939
3938
value = datetime .datetime .fromtimestamp (seconds , pytz .utc )
@@ -4698,8 +4697,7 @@ def __repr__(cls):
4698
4697
return "{}<{}>" .format (cls .__name__ , ", " .join (props ))
4699
4698
4700
4699
4701
- @six .add_metaclass (MetaModel )
4702
- class Model (_NotEqualMixin ):
4700
+ class Model (_NotEqualMixin , metaclass = MetaModel ):
4703
4701
"""A class describing Cloud Datastore entities.
4704
4702
4705
4703
Model instances are usually called entities. All model classes
@@ -4965,7 +4963,7 @@ def __init__(_self, **kwargs):
4965
4963
4966
4964
def _get_property_for (self , p , indexed = True , depth = 0 ):
4967
4965
"""Internal helper to get the Property for a protobuf-level property."""
4968
- if isinstance (p .name (), six . text_type ):
4966
+ if isinstance (p .name (), str ):
4969
4967
p .set_name (bytes (p .name (), encoding = "utf-8" ))
4970
4968
parts = p .name ().decode ().split ("." )
4971
4969
if len (parts ) <= depth :
@@ -5023,9 +5021,9 @@ def _from_pb(cls, pb, set_key=True, ent=None, key=None):
5023
5021
# A key passed in overrides a key in the pb.
5024
5022
if key is None and pb .key ().path .element_size ():
5025
5023
# modern NDB expects strings.
5026
- if not isinstance (pb .key_ .app_ , six . text_type ): # pragma: NO BRANCH
5024
+ if not isinstance (pb .key_ .app_ , str ): # pragma: NO BRANCH
5027
5025
pb .key_ .app_ = pb .key_ .app_ .decode ()
5028
- if not isinstance (pb .key_ .name_space_ , six . text_type ): # pragma: NO BRANCH
5026
+ if not isinstance (pb .key_ .name_space_ , str ): # pragma: NO BRANCH
5029
5027
pb .key_ .name_space_ = pb .key_ .name_space_ .decode ()
5030
5028
5031
5029
key = Key (reference = pb .key ())
@@ -5331,7 +5329,7 @@ def _fix_up_properties(cls):
5331
5329
an underscore.
5332
5330
"""
5333
5331
kind = cls ._get_kind ()
5334
- if not isinstance (kind , six . string_types ):
5332
+ if not isinstance (kind , str ):
5335
5333
raise KindError (
5336
5334
"Class {} defines a ``_get_kind()`` method that returns "
5337
5335
"a non-string ({!r})" .format (cls .__name__ , kind )
@@ -6061,7 +6059,7 @@ def _get_or_insert_async(_cls, _name, *args, **kwargs):
6061
6059
project = _cls ._get_arg (kwargs , "project" )
6062
6060
options = kwargs .pop ("_options" )
6063
6061
6064
- if not isinstance (name , six . string_types ):
6062
+ if not isinstance (name , str ):
6065
6063
raise TypeError ("'name' must be a string; received {!r}" .format (name ))
6066
6064
6067
6065
elif not name :
@@ -6666,10 +6664,10 @@ def get_indexes(**options):
6666
6664
def _unpack_user (v ):
6667
6665
"""Internal helper to unpack a User value from a protocol buffer."""
6668
6666
uv = v .uservalue ()
6669
- email = six . text_type (uv .email ().decode ("utf-8" ))
6670
- auth_domain = six . text_type (uv .auth_domain ().decode ("utf-8" ))
6667
+ email = str (uv .email ().decode ("utf-8" ))
6668
+ auth_domain = str (uv .auth_domain ().decode ("utf-8" ))
6671
6669
obfuscated_gaiaid = uv .obfuscated_gaiaid ().decode ("utf-8" )
6672
- obfuscated_gaiaid = six . text_type (obfuscated_gaiaid )
6670
+ obfuscated_gaiaid = str (obfuscated_gaiaid )
6673
6671
6674
6672
value = User (
6675
6673
email = email ,
0 commit comments