From 43e11878dc3b56c7fcba12742b82c83ab449ae7d Mon Sep 17 00:00:00 2001 From: rpessoa Date: Mon, 4 Nov 2024 17:10:42 +0000 Subject: [PATCH 1/4] [FEATURE] Adds pre-commit hooks, Makefile recipe and Github action - AIL-162 --- .github/workflows/ci.yml | 17 +++++++++++++++++ .pre-commit-config.yaml | 18 ++++++++++++++++++ ChangeLog.md | 7 +++++-- setup.py | 1 + 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70f0f2f..01720ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,23 @@ on: pull_request: jobs: + pre_commit: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install Pre-commit Dependencies + run: pip install pre-commit + + - name: Run Pre-commit Hooks + run: pre-commit run --all-files + tests: runs-on: ubuntu-latest strategy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9e969a6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-yaml + - id: check-json + - id: pretty-format-json + args: [ --autofix ] + - id: check-merge-conflict + - id: check-symlinks + - id: detect-private-key + + - repo: https://github.com/crate-ci/typos + rev: v1.26.8 + hooks: + - id: typos diff --git a/ChangeLog.md b/ChangeLog.md index 88f59c7..5f04280 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Deprecation warning for `datetime.utcnow()` +### Added +- Added pre-commit hooks and Github CI action for code formatting and linting. + ## [v0.3.10] - 2024-10-16 ### Security - Bump certifi minimum version to 2024.07.04 @@ -74,9 +77,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [v0.3.1] - 2019-08-07 ### Fixed -- Fixed an issue where the `DataApi` class's `results_iter` method would return no data +- Fixed an issue where the `DataApi` class's `results_iter` method would return no data when receiving responses from Data API endpoints that set the "`data`" field of the - response to an object (like the [itembank/questions endpoint](https://reference.learnosity.com/data-api/endpoints/itembank_endpoints#getQuestions) + response to an object (like the [itembank/questions endpoint](https://reference.learnosity.com/data-api/endpoints/itembank_endpoints#getQuestions) when `item_references` is included in the request). ## [v0.3.0] - 2019-06-17 diff --git a/setup.py b/setup.py index f0b932e..78079ef 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ ] DEV_REQUIRES = [ + 'pre-commit', 'setuptools', 'twine', 'wheel', From facfdb27a7668f4a61985104d9c9c98c3543a07b Mon Sep 17 00:00:00 2001 From: rpessoa Date: Mon, 4 Nov 2024 17:12:59 +0000 Subject: [PATCH 2/4] [POLISH] Fixes files according to pre-commit rules - AIL-162 --- .github/dependabot.yml | 4 ++-- CONTRIBUTING.md | 2 +- README.md | 14 +++++++------- REFERENCE.md | 4 ++-- docs/quickstart/config.py | 4 ++-- learnosity_sdk/request/init.py | 2 +- tests/integration/test_dataapi.py | 2 +- tests/unit/test_dataapi.py | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b869b0f..4356ec3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,5 +5,5 @@ updates: schedule: interval: "daily" time: "09:00" - reviewers: - - "@Learnosity/ai-labs-dev" \ No newline at end of file + reviewers: + - "@Learnosity/ai-labs-dev" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 58c6197..328ab94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Contribution in the form of [PRs] are welcome. -Why We Are No Longer Accepting Public Issues +Why We Are No Longer Accepting Public Issues After careful consideration, we’ve decided to discontinue accepting issues via GitHub Issues for our public repositories. Here’s why: diff --git a/README.md b/README.md index f587553..7b9f8b7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

Learnosity SDK - Python

-

Everything you need to start building your app in Learnosity, with the Python programming language.
+

Everything you need to start building your app in Learnosity, with the Python programming language.
(Prefer another language? Click here)
An official Learnosity open-source project.

@@ -72,7 +72,7 @@ Then, if you're following the tutorial on this page, also run: pip install learnosity_sdk[quickstart] ### **Alternative method 1: download the zip file** -Download the latest version of the SDK as a self-contained ZIP file from the [GitHub Releases](https://github.com/Learnosity/learnosity-sdk-python/releases) page. The distribution ZIP file contains all the necessary dependencies. +Download the latest version of the SDK as a self-contained ZIP file from the [GitHub Releases](https://github.com/Learnosity/learnosity-sdk-python/releases) page. The distribution ZIP file contains all the necessary dependencies. Note: after installation, run this command in the SDK root folder: @@ -163,7 +163,7 @@ host = "localhost" port = 8000 ``` -Now we'll declare the configuration parameters for Items API. These specify which assessment content should be rendered, how it should be displayed, which user is taking this assessment and how their responses should be stored. +Now we'll declare the configuration parameters for Items API. These specify which assessment content should be rendered, how it should be displayed, which user is taking this assessment and how their responses should be stored. ``` python items_request = { @@ -252,10 +252,10 @@ The call to `init()` returns an instance of the ItemsApp, which we can use to pr The Jinja template is rendered by the following line, which will bring in those variables. ``` python - response = template.render(name='Standalone Assessment Example', generated_request=generated_request) + response = template.render(name='Standalone Assessment Example', generated_request=generated_request) ``` -There is some additional code in [standalone_assessment.py](docs/quickstart/assessment/standalone_assessment.py), which runs Python's built-in web server. +There is some additional code in [standalone_assessment.py](docs/quickstart/assessment/standalone_assessment.py), which runs Python's built-in web server. This marks the end of the quick start guide. From here, try modifying the example files yourself, you are welcome to use this code as a basis for your own projects. As mentioned earlier, the Jinja template used here can be easily re-used in another framework, for example Python Flask or Django. @@ -271,7 +271,7 @@ See a more detailed breakdown of all the SDK features, and examples of how to us ### **Additional quick start guides** There are more quick start guides, going beyond the initial quick start topic of loading an assessment, these further tutorials show how to set up authoring and analytics: * [Authoring Items quick start guide](https://help.learnosity.com/hc/en-us/articles/360000754958-Getting-Started-With-the-Author-API) (Author API) - create and edit new Questions and Items for your Item bank, then group your assessment Items into Activities, and -* [Analytics / student reporting quick start guide](https://help.learnosity.com/hc/en-us/articles/360000755838-Getting-Started-With-the-Reports-API) (Reports API) - view the results and scores from an assessment Activity. +* [Analytics / student reporting quick start guide](https://help.learnosity.com/hc/en-us/articles/360000755838-Getting-Started-With-the-Reports-API) (Reports API) - view the results and scores from an assessment Activity. ### **Learnosity demos repository** On our [demo site](https://demos.learnosity.com/), browse through many examples of Learnosity API integration. You can also download the entire demo site source code, the code for any single demo, or browse the codebase directly on GitHub. @@ -318,7 +318,7 @@ We use this data to enable better support and feature planning. [(Back to top)](#table-of-contents) ## Further reading -Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites: +Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites: * [help.learnosity.com](http://help.learnosity.com/hc/en-us) -- general help portal and tutorials, * [reference.learnosity.com](http://reference.learnosity.com) -- developer reference site, and diff --git a/REFERENCE.md b/REFERENCE.md index bc952c0..3ac01a6 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -292,11 +292,11 @@ print(signed_request) ``` ## Further reading -Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites: +Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites: -Back to [README.md](README.md) \ No newline at end of file +Back to [README.md](README.md) diff --git a/docs/quickstart/config.py b/docs/quickstart/config.py index 61084dd..4e4f2c9 100644 --- a/docs/quickstart/config.py +++ b/docs/quickstart/config.py @@ -1,8 +1,8 @@ # The consumerKey and consumerSecret are the public & private # security keys required to access Learnosity APIs and # data. Learnosity will provide keys for your own private account. -# Note: The consumer secret should be in a properly secured credential store, -# and *NEVER* checked into version control. +# Note: The consumer secret should be in a properly secured credential store, +# and *NEVER* checked into version control. # The keys listed here grant access to Learnosity's public demos account. consumer_key = 'yis0TYCu7U9V4o7M' diff --git a/learnosity_sdk/request/init.py b/learnosity_sdk/request/init.py index 90474e2..cab08fd 100644 --- a/learnosity_sdk/request/init.py +++ b/learnosity_sdk/request/init.py @@ -130,7 +130,7 @@ def generate_signature(self) -> str: vals = [] # Add each valid security field. - # The order is signifcant. + # The order is significant. for key in self.security_keys: if key in self.security: vals.append(self.security[key]) diff --git a/tests/integration/test_dataapi.py b/tests/integration/test_dataapi.py index 9df141e..bfd5a42 100644 --- a/tests/integration/test_dataapi.py +++ b/tests/integration/test_dataapi.py @@ -11,7 +11,7 @@ } # WARNING: Normally the consumer secret should not be committed to a public -# repository like this one. Only this specific key is publically available. +# repository like this one. Only this specific key is publicly available. consumer_secret = '74c5fd430cf1242a527f6223aebd42d30464be22' action = 'get' diff --git a/tests/unit/test_dataapi.py b/tests/unit/test_dataapi.py index c98c012..68fad2a 100644 --- a/tests/unit/test_dataapi.py +++ b/tests/unit/test_dataapi.py @@ -16,7 +16,7 @@ def setUp(self): 'domain': 'demos.learnosity.com' } # WARNING: Normally the consumer secret should not be committed to a public - # repository like this one. Only this specific key is publically available. + # repository like this one. Only this specific key is publicly available. self.consumer_secret = '74c5fd430cf1242a527f6223aebd42d30464be22' self.request = { # These items should already exist for the demos consumer From 3cdd98ddca25a779e7902cf35d95f9368b5f6632 Mon Sep 17 00:00:00 2001 From: rpessoa Date: Tue, 5 Nov 2024 11:00:25 +0000 Subject: [PATCH 3/4] [CHANGE] Implements code review changes - AIL-162 --- ChangeLog.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5f04280..423c247 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [v0.3.11] - 2024-11-01 +## [unreleased] - 2024-11-01 ### Fixed - Deprecation warning for `datetime.utcnow()` diff --git a/setup.py b/setup.py index 78079ef..364eec3 100644 --- a/setup.py +++ b/setup.py @@ -13,13 +13,13 @@ ] DEV_REQUIRES = [ - 'pre-commit', 'setuptools', 'twine', 'wheel', ] TEST_REQUIRES = [ + 'pre-commit', 'pytest >=4.6.6', 'pytest-cov >=2.8.1', 'pytest-subtests', From 4a89f9b235c101f221839018aeab3fdbbebb62c5 Mon Sep 17 00:00:00 2001 From: rpessoa Date: Tue, 5 Nov 2024 11:10:00 +0000 Subject: [PATCH 4/4] Oops --- ChangeLog.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 423c247..2989ef3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,12 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [unreleased] - 2024-11-01 -### Fixed -- Deprecation warning for `datetime.utcnow()` - ### Added - Added pre-commit hooks and Github CI action for code formatting and linting. +## [v0.3.11] - 2024-11-01 +### Fixed +- Deprecation warning for `datetime.utcnow()` + ## [v0.3.10] - 2024-10-16 ### Security - Bump certifi minimum version to 2024.07.04