Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SG-33057 App pre-commit configuration and CI #367

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

[flake8]
max-line-length = 120
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ build
dist
shotgun_api3.egg-info
/%1

49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2024, Shotgun Software Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# - Neither the name of the Shotgun Software Inc nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Styles the code properly

# Exclude Third Pary components
exclude: "shotgun_api3/lib/.*"

# List of super useful formatters.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
72 changes: 36 additions & 36 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ v3.4.2 (2024 Feb 6)
v3.4.1 (2024 Jan 29)
====================
- Flaky Tests
- Documentation: Fix issue regarding "in" filter prototype
- Documentation: Fix issue regarding "in" filter prototype
- Documentation: Travis badge image is no working anymore
- Documentation: Add ``user_subscription_read`` and ``user_subscription_create`` methods
- Update Python Certifi license block
Expand Down Expand Up @@ -199,7 +199,7 @@ v3.0.34 (2017 September 18)
v3.0.33 (2017 July 18)
======================

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

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

v3.0.25 (2016 Jan 12)
=====================

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

v3.0.24 (2016 Jan 08)
=====================

- Not released.

v3.0.23 (2015 Oct 26)
=====================

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

v3.0.22 (2015 Sept 9)
=====================

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

Expand All @@ -304,23 +304,23 @@ v3.0.19 (2015 Mar 25)

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

v3.0.18 (2015 Mar 13)
=====================

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

v3.0.17 (2014 Jul 10)
=====================

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

Expand All @@ -334,7 +334,7 @@ v3.0.16 (2014 May 23)
v3.0.15 (2014 Mar 6)
====================

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

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

v3.0.13 (2013 Apr 11)
=====================

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

v3.0.12 (2013 Feb 22)
=====================
*no tag*

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

v3.0.11 (2013 Jan 31)
Expand All @@ -374,21 +374,21 @@ v3.0.11 (2013 Jan 31)
v3.0.10 (2013 Jan 25)
=====================

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

v3.0.9 (2012 Dec 05)
====================

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

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

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

v3.0.7 (2011 Apr 04)
Expand Down Expand Up @@ -464,15 +464,15 @@ v3.0.2 (2010 Aug 27)
v3.0.1 (2010 May 10)
====================

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

v3.0 (2010 May 5)
=================

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

v3.0b8 (2010 Feb 19)
Expand All @@ -489,7 +489,7 @@ v3.0b7 (2009 Nov 30)
v3.0b6 (2009 Oct 20)
====================

- add support for ``HTTP/1.1 keepalive``, which greatly improves performance for multiple
- add support for ``HTTP/1.1 keepalive``, which greatly improves performance for multiple
requests.
- add more helpful error if server entered is not ``http`` or ``https``
- add support assigning tags to file uploads (for Shotgun version >= 1.10.6).
Expand All @@ -513,6 +513,6 @@ v3.0b3 (2009 June 24)
- added ``schema_*`` methods for accessing entities and fields.
- added support for http proxy servers.
- added ``__version__`` string.
- removed ``RECORDS_PER_PAGE`` global (can just set ``records_per_page`` on the Shotgun object
- removed ``RECORDS_PER_PAGE`` global (can just set ``records_per_page`` on the Shotgun object
after initializing it).
- removed ``api_ver`` from the constructor, as this class is only designed to work with API v3.
8 changes: 4 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither the name of the Shotgun Software Inc nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
Expand Down Expand Up @@ -51,4 +51,4 @@ BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
OF THIS SOFTWARE.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ configurations, reproduction steps, exploit code, impact, etc.

## Additional Information

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).
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).
50 changes: 50 additions & 0 deletions azure-pipelines-templates/code_style_validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) 2024, Shotgun Software Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# - Neither the name of the Shotgun Software Inc nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

jobs:
- job: code_style_validation
displayName: Code Style Validation
pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.9
addToPath: True
architecture: 'x64'

- script: |
pip install --upgrade pip setuptools wheel
pip install --upgrade pre-commit
displayName: Install dependencies

- bash: pre-commit autoupdate
displayName: Update pre-commit hook versions

- bash: pre-commit run --all
displayName: Validate code with pre-commit
6 changes: 3 additions & 3 deletions azure-pipelines-templates/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ parameters:
jobs:
# The job will be named after the OS and Azure will suffix the strategy to make it unique
# so we'll have a job name "Windows Python27" for example. What's a strategy? Strategies are the
# name of the keys under the strategy.matrix scope. So for each OS we'll have "<OS> Python27" and
# name of the keys under the strategy.matrix scope. So for each OS we'll have "<OS> Python27" and
# "<OS> Python37".
- job: ${{ parameters.name }}
pool:
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
# Specifies which version of Python we want to use. That's where the strategy comes in.
# Each job will share this set of steps, but each of them will receive a different
# $(python.version)
# TODO: We should provide `githubToken` if we want to download a python release.
# TODO: We should provide `githubToken` if we want to download a python release.
# Otherwise we may hit the GitHub anonymous download limit.
- task: UsePythonVersion@0
inputs:
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
.\codecov.exe -f coverage.xml
displayName: Uploading code coverage
- ${{ elseif eq(parameters.name, 'Linux') }}:
- ${{ elseif eq(parameters.name, 'Linux') }}:
- script: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
Expand Down
Loading