Skip to content

Commit 2cd8b38

Browse files
authored
SG-33057 App pre-commit configuration and CI (#367)
* Add pre-commit config * Apply pre-commit reformat * fixup! Add pre-commit config
1 parent b6247a3 commit 2cd8b38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3617
-2501
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
[flake8]
1212
max-line-length = 120
13-
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py
13+
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ build
3333
dist
3434
shotgun_api3.egg-info
3535
/%1
36-

.pre-commit-config.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright (c) 2024, Shotgun Software Inc.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions are met:
5+
#
6+
# - Redistributions of source code must retain the above copyright notice, this
7+
# list of conditions and the following disclaimer.
8+
#
9+
# - Redistributions in binary form must reproduce the above copyright notice,
10+
# this list of conditions and the following disclaimer in the documentation
11+
# and/or other materials provided with the distribution.
12+
#
13+
# - Neither the name of the Shotgun Software Inc nor the names of its
14+
# contributors may be used to endorse or promote products derived from this
15+
# software without specific prior written permission.
16+
#
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
# Styles the code properly
29+
30+
# Exclude Third Pary components
31+
exclude: "shotgun_api3/lib/.*"
32+
33+
# List of super useful formatters.
34+
repos:
35+
- repo: https://github.com/pre-commit/pre-commit-hooks
36+
rev: v5.0.0
37+
hooks:
38+
- id: check-ast
39+
- id: check-case-conflict
40+
- id: check-executables-have-shebangs
41+
- id: check-merge-conflict
42+
- id: end-of-file-fixer
43+
- id: requirements-txt-fixer
44+
- id: trailing-whitespace
45+
46+
- repo: https://github.com/psf/black
47+
rev: 25.1.0
48+
hooks:
49+
- id: black

HISTORY.rst

+37-37
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ v3.8.0 (2024 Feb 7)
99

1010
- Extend the payload optimizations to the ``in`` and ``not_in`` filters and
1111
the ``update`` method.
12-
- The payload optimization is now enabled by default.
12+
- The payload optimization is now enabled by default.
1313
It can be disabled with the ``SHOTGUN_API_DISABLE_ENTITY_OPTIMIZATION``
1414
environment variable.
1515

@@ -57,7 +57,7 @@ v3.4.2 (2024 Feb 6)
5757
v3.4.1 (2024 Jan 29)
5858
====================
5959
- Flaky Tests
60-
- Documentation: Fix issue regarding "in" filter prototype
60+
- Documentation: Fix issue regarding "in" filter prototype
6161
- Documentation: Travis badge image is no working anymore
6262
- Documentation: Add ``user_subscription_read`` and ``user_subscription_create`` methods
6363
- Update Python Certifi license block
@@ -208,7 +208,7 @@ v3.0.34 (2017 September 18)
208208
v3.0.33 (2017 July 18)
209209
======================
210210

211-
- Raise an exception when uploading an empty file using :meth:`upload`, :meth:`upload_thumbnail`
211+
- Raise an exception when uploading an empty file using :meth:`upload`, :meth:`upload_thumbnail`
212212
or :meth:`upload_filmstrip_thumbnail` before calling out to the server.
213213
- Multiple enhancements and bugfixes to Mockgun
214214
- Added ``nav_search_string()`` and ``nav_search_entity()`` methods as experimental, internal methods for querying SG hierarchy.
@@ -258,43 +258,43 @@ v3.0.27 (2016 Feb 18)
258258
v3.0.26 (2016 Feb 1)
259259
====================
260260

261-
- Updating testing framework to use environment variables inconjunction with existing
261+
- Updating testing framework to use environment variables inconjunction with existing
262262
``example_config`` file so that commits and pull requests are automatically run on travis-ci.
263-
- Fix to prevent stripping out case-sensitivity of a URL if the user passes their credentials to
263+
- Fix to prevent stripping out case-sensitivity of a URL if the user passes their credentials to
264264
``config.server`` as an authorization header.
265265

266266
v3.0.25 (2016 Jan 12)
267267
=====================
268268

269-
- Add handling for Python versions incompatible with SHA-2 (see `this blog post
269+
- Add handling for Python versions incompatible with SHA-2 (see `this blog post
270270
<https://www.shotgridsoftware.com/blog/important-ssl-certificate-renewal-and-sha-2/>`_).
271-
- Add ``SHOTGUN_FORCE_CERTIFICATE_VALIDATION`` environment variable to prevent disabling certficate
271+
- Add ``SHOTGUN_FORCE_CERTIFICATE_VALIDATION`` environment variable to prevent disabling certficate
272272
validation when SHA-2 validation is not available.
273273
- Add SSL info to user-agent header.
274274

275275
v3.0.24 (2016 Jan 08)
276276
=====================
277277

278278
- Not released.
279-
279+
280280
v3.0.23 (2015 Oct 26)
281281
=====================
282282

283-
- Fix for `python bug #23371 <http://bugs.python.org/issue23371>`_ on Windows loading mimetypes
283+
- Fix for `python bug #23371 <http://bugs.python.org/issue23371>`_ on Windows loading mimetypes
284284
module (thanks `@patrickwolf <http://github.com/patrickwolf>`_).
285285
- Fix for tests on older versions of python.
286286
- Sanitize authentication values before raising error.
287287

288288
v3.0.22 (2015 Sept 9)
289289
=====================
290290

291-
- Added method :meth:`text_search` which allows an API client to access the Shotgun global search
291+
- Added method :meth:`text_search` which allows an API client to access the Shotgun global search
292292
and auto completer.
293-
- Added method :meth:`activity_stream_read` which allows an API client to access the activity
293+
- Added method :meth:`activity_stream_read` which allows an API client to access the activity
294294
stream for a given Shotgun entity.
295-
- Added method :meth:`note_thread_read` which allows an API client to download an entire Note
295+
- Added method :meth:`note_thread_read` which allows an API client to download an entire Note
296296
conversation, including Replies and Attachments, using a single API call.
297-
- Added an experimental ``mockgun`` module which can be used to emulate the Shotgun API, for
297+
- Added an experimental ``mockgun`` module which can be used to emulate the Shotgun API, for
298298
example inside unit test rigs.
299299
- [minor] Improved docstrings.
300300

@@ -313,23 +313,23 @@ v3.0.19 (2015 Mar 25)
313313

314314
- Add ability to authenticate with Shotgun using ``session_token``.
315315
- Add :meth:`get_session_token` method for obtaining token to authenticate with.
316-
- Add new ``AuthenticationFault`` exception type to indicate when server communication has failed
316+
- Add new ``AuthenticationFault`` exception type to indicate when server communication has failed
317317
due to authentication reasons.
318-
- Add support for ``SHOTGUN_API_CACERTS`` environment variable to provide location of external
318+
- Add support for ``SHOTGUN_API_CACERTS`` environment variable to provide location of external
319319
SSL certificates file.
320320
- Fixes and updates to various tests.
321321

322322
v3.0.18 (2015 Mar 13)
323323
=====================
324324

325-
- Add ability to query the per-project visibility status for entities, fields and statuses.
325+
- Add ability to query the per-project visibility status for entities, fields and statuses.
326326
(requires Shotgun server >= v5.4.4)
327327

328328
v3.0.17 (2014 Jul 10)
329329
=====================
330330

331331
- Add ability to update ``last_accessed_by_current_user`` on Project.
332-
- Add workaround for `bug #9291 in Python 2.7 <http://bugs.python.org/issue9291>`_ affecting
332+
- Add workaround for `bug #9291 in Python 2.7 <http://bugs.python.org/issue9291>`_ affecting
333333
mimetypes library on Windows.
334334
- Add platform and Python version to user-agent (eg. ``shotgun-json (3.0.17); Python 2.7 (Mac)``)
335335

@@ -343,7 +343,7 @@ v3.0.16 (2014 May 23)
343343
v3.0.15 (2014 Mar 6)
344344
====================
345345

346-
- Fixed bug which allowed a value of ``None`` for password parameter in
346+
- Fixed bug which allowed a value of ``None`` for password parameter in
347347
:meth:`authenticate_human_user`
348348
- Add :meth:`follow`, :meth:`unfollow` and :meth:`followers` methods.
349349
- Add ability to login as HumanUser.
@@ -355,24 +355,24 @@ v3.0.14 (2013 Jun 26)
355355
=====================
356356

357357
- added: additional tests for thumbnails.
358-
- added: support for downloading from s3 in :meth:`download_attachment`. Accepts an Attachment
359-
entity dict as a parameter (is still backwards compatible with passing in an Attachment id).
360-
- added: optional ``file_path`` parameter to :meth:`download_attachment` to write data directly to
358+
- added: support for downloading from s3 in :meth:`download_attachment`. Accepts an Attachment
359+
entity dict as a parameter (is still backwards compatible with passing in an Attachment id).
360+
- added: optional ``file_path`` parameter to :meth:`download_attachment` to write data directly to
361361
disk instead of loading into memory. (thanks to Adam Goforth `@aag <https://github.com/aag>`_)
362362

363363
v3.0.13 (2013 Apr 11)
364364
=====================
365365

366-
- fixed: #20856 :meth:`authenticate_human_user` login was sticky and would be used for permissions
366+
- fixed: #20856 :meth:`authenticate_human_user` login was sticky and would be used for permissions
367367
and logging.
368368

369369
v3.0.12 (2013 Feb 22)
370370
=====================
371371
*no tag*
372372

373-
- added: #18171 New ``ca_certs`` argument to the :class:`Shotgun` constructor to specify the
373+
- added: #18171 New ``ca_certs`` argument to the :class:`Shotgun` constructor to specify the
374374
certificates to use in SSL validation.
375-
- added: ``setup.py`` doesn't compress the installed ``.egg`` file which makes the
375+
- added: ``setup.py`` doesn't compress the installed ``.egg`` file which makes the
376376
``cacerts.txt`` file accessible.
377377

378378
v3.0.11 (2013 Jan 31)
@@ -383,21 +383,21 @@ v3.0.11 (2013 Jan 31)
383383
v3.0.10 (2013 Jan 25)
384384
=====================
385385

386-
- added: :meth:`add_user_agent()` and :meth:`reset_user_agent` methods to allow client code to add
386+
- added: :meth:`add_user_agent()` and :meth:`reset_user_agent` methods to allow client code to add
387387
strings to track.
388-
- added: Changed default ``user-agent`` to include API version.
388+
- added: Changed default ``user-agent`` to include API version.
389389
- updated: advanced summarize filter support.
390390
- fixed: #19830 :meth:`share_thumbnail` errors when source has no thumbnail.
391391

392392
v3.0.9 (2012 Dec 05)
393393
====================
394394

395-
- added: :meth:`share_thumbnail` method to share the same thumbnail record and media between
395+
- added: :meth:`share_thumbnail` method to share the same thumbnail record and media between
396396
entities.
397-
- added: proxy handling to methods that transfer binary data (ie. :meth:`upload`,
397+
- added: proxy handling to methods that transfer binary data (ie. :meth:`upload`,
398398
:meth:`upload_thumbnail`, etc.).
399399
- updated: default logging level to WARN.
400-
- updated: documentation for :meth:`summarize()` method, previously released but without
400+
- updated: documentation for :meth:`summarize()` method, previously released but without
401401
documentation.
402402
- fixed: unicode strings not always being encoded correctly.
403403
- fixed: :meth:`create()` generates error when ``return_fields`` is None.
@@ -411,10 +411,10 @@ v3.0.9.beta2 (2012 Mar 19)
411411
==========================
412412

413413
- use relative imports for included libraries when using Python v2.5 or later.
414-
- replace sideband request for ``image`` (thumbnail) field with native support (requires Shotgun
415-
server >= v3.3.0. Request will still work on older versions but fallback to slow sideband
414+
- replace sideband request for ``image`` (thumbnail) field with native support (requires Shotgun
415+
server >= v3.3.0. Request will still work on older versions but fallback to slow sideband
416416
method).
417-
- allow setting ``image`` and ``filmstrip_thumbnail`` in data dict on :meth:`create` and
417+
- allow setting ``image`` and ``filmstrip_thumbnail`` in data dict on :meth:`create` and
418418
:meth:`update` (thanks `@hughmacdonald <https://github.com/HughMacdonald>`_).
419419
- fixed bug causing ``Attachment.tag_list`` to be set to ``"None"`` (str) for uploads.
420420

@@ -433,7 +433,7 @@ v3.0.8 (2011 Oct 7)
433433
- added the :meth:`summarize` method.
434434
- refactored single file into package.
435435
- tests added (Thanks to Aaron Morton `@amorton <https://github.com/amorton>`_).
436-
- return all strings as ascii for backwards compatibility, added ``ensure_ascii`` parameter to
436+
- return all strings as ascii for backwards compatibility, added ``ensure_ascii`` parameter to
437437
enable returning unicode.
438438

439439
v3.0.7 (2011 Apr 04)
@@ -473,15 +473,15 @@ v3.0.2 (2010 Aug 27)
473473
v3.0.1 (2010 May 10)
474474
====================
475475

476-
- :meth:`find`: default sorting to ascending, if not set (instead of requiring
476+
- :meth:`find`: default sorting to ascending, if not set (instead of requiring
477477
ascending/descending).
478478
- :meth:`upload` and :meth:`upload_thumbnail`: pass auth info through.
479479

480480
v3.0 (2010 May 5)
481481
=================
482482

483483
- non-beta!
484-
- add :meth:`batch` method to do multiple :meth:`create`, :meth:`update`, and :meth:`delete`
484+
- add :meth:`batch` method to do multiple :meth:`create`, :meth:`update`, and :meth:`delete`
485485
operations in one request to the server (requires Shotgun server to be v1.13.0 or higher).
486486

487487
v3.0b8 (2010 Feb 19)
@@ -498,7 +498,7 @@ v3.0b7 (2009 Nov 30)
498498
v3.0b6 (2009 Oct 20)
499499
====================
500500

501-
- add support for ``HTTP/1.1 keepalive``, which greatly improves performance for multiple
501+
- add support for ``HTTP/1.1 keepalive``, which greatly improves performance for multiple
502502
requests.
503503
- add more helpful error if server entered is not ``http`` or ``https``
504504
- add support assigning tags to file uploads (for Shotgun version >= 1.10.6).
@@ -522,6 +522,6 @@ v3.0b3 (2009 June 24)
522522
- added ``schema_*`` methods for accessing entities and fields.
523523
- added support for http proxy servers.
524524
- added ``__version__`` string.
525-
- removed ``RECORDS_PER_PAGE`` global (can just set ``records_per_page`` on the Shotgun object
525+
- removed ``RECORDS_PER_PAGE`` global (can just set ``records_per_page`` on the Shotgun object
526526
after initializing it).
527527
- removed ``api_ver`` from the constructor, as this class is only designed to work with API v3.

LICENSE

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ Redistribution and use in source and binary forms, with or without
55
modification, are permitted provided that the following conditions are met:
66

77
- Redistributions of source code must retain the above copyright notice, this
8-
list of conditions and the following disclaimer.
9-
8+
list of conditions and the following disclaimer.
9+
1010
- Redistributions in binary form must reproduce the above copyright notice,
1111
this list of conditions and the following disclaimer in the documentation
1212
and/or other materials provided with the distribution.
13-
13+
1414
- Neither the name of the Shotgun Software Inc nor the names of its
1515
contributors may be used to endorse or promote products derived from this
1616
software without specific prior written permission.
@@ -51,4 +51,4 @@ BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
5151
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
5252
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
5353
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
54-
OF THIS SOFTWARE.
54+
OF THIS SOFTWARE.

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ configurations, reproduction steps, exploit code, impact, etc.
3232

3333
## Additional Information
3434

35-
Please check out the [Flow Production Tracking Security White Paper](https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Administrator_ar_general_security_ar_security_white_paper_html).
35+
Please check out the [Flow Production Tracking Security White Paper](https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Administrator_ar_general_security_ar_security_white_paper_html).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2024, Shotgun Software Inc.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions are met:
5+
#
6+
# - Redistributions of source code must retain the above copyright notice, this
7+
# list of conditions and the following disclaimer.
8+
#
9+
# - Redistributions in binary form must reproduce the above copyright notice,
10+
# this list of conditions and the following disclaimer in the documentation
11+
# and/or other materials provided with the distribution.
12+
#
13+
# - Neither the name of the Shotgun Software Inc nor the names of its
14+
# contributors may be used to endorse or promote products derived from this
15+
# software without specific prior written permission.
16+
#
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
jobs:
29+
- job: code_style_validation
30+
displayName: Code Style Validation
31+
pool:
32+
vmImage: 'ubuntu-latest'
33+
34+
steps:
35+
- task: UsePythonVersion@0
36+
inputs:
37+
versionSpec: 3.9
38+
addToPath: True
39+
architecture: 'x64'
40+
41+
- script: |
42+
pip install --upgrade pip setuptools wheel
43+
pip install --upgrade pre-commit
44+
displayName: Install dependencies
45+
46+
- bash: pre-commit autoupdate
47+
displayName: Update pre-commit hook versions
48+
49+
- bash: pre-commit run --all
50+
displayName: Validate code with pre-commit

0 commit comments

Comments
 (0)