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

Commita30f004

Browse files
authored
fix!: drop support for Python 2.7 / 3.5 (#212)
Drop 'six' moduleDrop 'u"' prefixes for textRemove other Python 2.7 workaroundsDrop use of 'pytz'Dxpand range to allow 'google-auth' 2.x versionsRemove 'general_helpers.wraps': except for a backward-compatibilityimport, 'functools.wraps' does everything wee need on Python >= 3.6.Remove 'packaging' dependencyRelease-As: 2.0.0b1Closes#74.Closes#215.
1 parentff6ef1b commita30f004

35 files changed

+191
-349
lines changed

‎CONTRIBUTING.rst‎

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.. Generated by synthtool. DO NOT EDIT!
21
############
32
Contributing
43
############
@@ -22,7 +21,7 @@ In order to add a feature:
2221
documentation.
2322

2423
- The feature must work fully on the following CPython versions:
25-
2.7,3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
24+
3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
2625

2726
- The feature must not add unnecessary dependencies (where
2827
"unnecessary" is of course subjective, but new dependencies should
@@ -77,8 +76,8 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
7776

7877
.. note::
7978

80-
The unit testsand systemtests are described in the
81-
``noxfile.py`` filesin each directory.
79+
The unit tests tests are described in the ``noxfile.py`` files
80+
in each directory.
8281

8382
.. nox: https://pypi.org/project/nox/
8483
@@ -133,29 +132,6 @@ Exceptions to PEP8:
133132
"Function-Under-Test"), which is PEP8-incompliant, but more readable.
134133
Some also use a local variable, ``MUT`` (short for "Module-Under-Test").
135134

136-
********************
137-
Running System Tests
138-
********************
139-
140-
- To run system tests, you can execute::
141-
142-
# Run all system tests
143-
$ nox -s system
144-
145-
# Run a single system test
146-
$ nox -s system-3.8 -- -k <name of test>
147-
148-
149-
.. note::
150-
151-
System tests are only configured to run under Python 2.7 and 3.8.
152-
For expediency, we do not run them in older versions of Python 3.
153-
154-
This alone will not run the tests. You'll need to change some local
155-
auth settings and change some configuration in your project to
156-
run all the tests.
157-
158-
- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication<https://cloud.google.com/docs/authentication/best-practices-applications#local_development_and_testing_with_the>`__. Some tests require a service account. For those tests see `Authenticating as a service account<https://cloud.google.com/docs/authentication/production>`__.
159135

160136
*************
161137
Test Coverage
@@ -221,13 +197,11 @@ Supported Python Versions
221197

222198
We support:
223199

224-
- `Python 2.7`_
225200
- `Python 3.6`_
226201
- `Python 3.7`_
227202
- `Python 3.8`_
228203
- `Python 3.9`_
229204

230-
.. _Python 2.7:https://docs.python.org/2.7/
231205
.. _Python 3.6:https://docs.python.org/3.6/
232206
.. _Python 3.7:https://docs.python.org/3.7/
233207
.. _Python 3.8:https://docs.python.org/3.8/
@@ -239,7 +213,7 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
239213
.. _config:https://github.com/googleapis/python-api-core/blob/master/noxfile.py
240214

241215

242-
We also explicitly decided to support Python 3 beginning with version2.7.
216+
We also explicitly decided to support Python 3 beginning with version3.6.
243217
Reasons for this include:
244218

245219
- Encouraging use of newest versions of Python 3

‎README.rst‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Core Library for Google Client Libraries
22
========================================
33

4-
|pypi| |versions|
4+
|pypi| |versions|
55

66
This library is not meant to stand-alone. Instead it defines
77
common helpers used by all Google API clients. For more information, see the
@@ -16,8 +16,13 @@ common helpers used by all Google API clients. For more information, see the
1616

1717
Supported Python Versions
1818
-------------------------
19-
Python >= 3.5
19+
Python >= 3.6
2020

21-
Deprecated Python Versions
22-
--------------------------
23-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
21+
22+
Unsupported Python Versions
23+
---------------------------
24+
25+
Python == 2.7, Python == 3.5.
26+
27+
The last version of this library compatible with Python 2.7 and 3.5 is
28+
`google-api_core==1.31.1`.

‎docs/auth.rst‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,6 @@ After creation, you can pass it directly to a :class:`Client <google.cloud.clien
103103

104104
.. _google-auth-guide:https://googleapis.dev/python/google-auth/latest/user-guide.html#service-account-private-key-files
105105

106-
107-
Google App Engine Standard First Generation Environment
108-
-------------------------------------------------------
109-
110-
These credentials are used only in the legacy Python 2.7
111-
`First Generation Standard Environment`_. All other App Engine
112-
runtimes use Compute Engine credentials.
113-
114-
.. _First Generation Standard Environment:https://cloud.google.com/appengine/docs/standard/runtimes
115-
116-
To create
117-
:class:`credentials <google.auth.app_engine.Credentials>`
118-
just for Google App Engine:
119-
120-
..code::python
121-
122-
from google.authimport app_engine
123-
credentials= app_engine.Credentials()
124-
125106
Google Compute Engine Environment
126107
---------------------------------
127108

‎google/api_core/bidi.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
importcollections
1818
importdatetime
1919
importlogging
20+
importqueueasqueue_module
2021
importthreading
2122
importtime
2223

23-
fromsix.movesimportqueue
24-
2524
fromgoogle.api_coreimportexceptions
2625

2726
_LOGGER=logging.getLogger(__name__)
@@ -71,7 +70,7 @@ class _RequestQueueGenerator(object):
7170
CPU consumed by spinning is pretty minuscule.
7271
7372
Args:
74-
queue (queue.Queue): The request queue.
73+
queue (queue_module.Queue): The request queue.
7574
period (float): The number of seconds to wait for items from the queue
7675
before checking if the RPC is cancelled. In practice, this
7776
determines the maximum amount of time the request consumption
@@ -108,7 +107,7 @@ def __iter__(self):
108107
whileTrue:
109108
try:
110109
item=self._queue.get(timeout=self._period)
111-
exceptqueue.Empty:
110+
exceptqueue_module.Empty:
112111
ifnotself._is_active():
113112
_LOGGER.debug(
114113
"Empty queue and inactive call, exiting request ""generator."
@@ -247,7 +246,7 @@ def __init__(self, start_rpc, initial_request=None, metadata=None):
247246
self._start_rpc=start_rpc
248247
self._initial_request=initial_request
249248
self._rpc_metadata=metadata
250-
self._request_queue=queue.Queue()
249+
self._request_queue=queue_module.Queue()
251250
self._request_generator=None
252251
self._is_active=False
253252
self._callbacks= []
@@ -645,6 +644,7 @@ def _thread_main(self, ready):
645644
# Keeping the lock throughout avoids that.
646645
# In the future, we could use `Condition.wait_for` if we drop
647646
# Python 2.7.
647+
# See: https://github.com/googleapis/python-api-core/issues/211
648648
withself._wake:
649649
whileself._paused:
650650
_LOGGER.debug("paused, waiting for waking.")

‎google/api_core/client_info.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ClientInfo(object):
4242
4343
Args:
4444
python_version (str): The Python interpreter version, for example,
45-
``'2.7.13'``.
45+
``'3.9.6'``.
4646
grpc_version (Optional[str]): The gRPC library version.
4747
api_core_version (str): The google-api-core library version.
4848
gapic_version (Optional[str]): The sversion of gapic-generated client

‎google/api_core/client_options.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def from_dict(options):
101101
"""Construct a client options object from a mapping object.
102102
103103
Args:
104-
options (six.moves.collections_abc.Mapping): A mapping object with client options.
104+
options (collections.abc.Mapping): A mapping object with client options.
105105
See the docstring for ClientOptions for details on valid arguments.
106106
"""
107107

‎google/api_core/datetime_helpers.py‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
importdatetime
1919
importre
2020

21-
importpytz
22-
2321
fromgoogle.protobufimporttimestamp_pb2
2422

2523

26-
_UTC_EPOCH=datetime.datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc)
24+
_UTC_EPOCH=datetime.datetime(1970,1,1,tzinfo=datetime.timezone.utc)
2725
_RFC3339_MICROS="%Y-%m-%dT%H:%M:%S.%fZ"
2826
_RFC3339_NO_FRACTION="%Y-%m-%dT%H:%M:%S"
2927
# datetime.strptime cannot handle nanosecond precision: parse w/ regex
@@ -83,9 +81,9 @@ def to_microseconds(value):
8381
int: Microseconds since the unix epoch.
8482
"""
8583
ifnotvalue.tzinfo:
86-
value=value.replace(tzinfo=pytz.utc)
84+
value=value.replace(tzinfo=datetime.timezone.utc)
8785
# Regardless of what timezone is on the value, convert it to UTC.
88-
value=value.astimezone(pytz.utc)
86+
value=value.astimezone(datetime.timezone.utc)
8987
# Convert the datetime to a microsecond timestamp.
9088
returnint(calendar.timegm(value.timetuple())*1e6)+value.microsecond
9189

@@ -156,7 +154,7 @@ def from_rfc3339(value):
156154
nanos=int(fraction)* (10**scale)
157155
micros=nanos//1000
158156

159-
returnbare_seconds.replace(microsecond=micros,tzinfo=pytz.utc)
157+
returnbare_seconds.replace(microsecond=micros,tzinfo=datetime.timezone.utc)
160158

161159

162160
from_rfc3339_nanos=from_rfc3339# from_rfc3339_nanos method was deprecated.
@@ -256,7 +254,7 @@ def from_rfc3339(cls, stamp):
256254
bare.minute,
257255
bare.second,
258256
nanosecond=nanos,
259-
tzinfo=pytz.UTC,
257+
tzinfo=datetime.timezone.utc,
260258
)
261259

262260
deftimestamp_pb(self):
@@ -265,7 +263,11 @@ def timestamp_pb(self):
265263
Returns:
266264
(:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message
267265
"""
268-
inst=selfifself.tzinfoisnotNoneelseself.replace(tzinfo=pytz.UTC)
266+
inst= (
267+
self
268+
ifself.tzinfoisnotNone
269+
elseself.replace(tzinfo=datetime.timezone.utc)
270+
)
269271
delta=inst-_UTC_EPOCH
270272
seconds=int(delta.total_seconds())
271273
nanos=self._nanosecondorself.microsecond*1000
@@ -292,5 +294,5 @@ def from_timestamp_pb(cls, stamp):
292294
bare.minute,
293295
bare.second,
294296
nanosecond=stamp.nanos,
295-
tzinfo=pytz.UTC,
297+
tzinfo=datetime.timezone.utc,
296298
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp