Skip to content

Commit 6477330

Browse files
Ail 162/feature/setup precommit basic linting (#95)
[FEATURE] Adds pre-commit hooks and Github action for basic linting - AIL-162
1 parent 0e43bf5 commit 6477330

File tree

12 files changed

+59
-19
lines changed

12 files changed

+59
-19
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ updates:
55
schedule:
66
interval: "daily"
77
time: "09:00"
8-
reviewers:
9-
- "@Learnosity/ai-labs-dev"
8+
reviewers:
9+
- "@Learnosity/ai-labs-dev"

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ on:
66
pull_request:
77

88
jobs:
9+
pre_commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.9'
19+
20+
- name: Install Pre-commit Dependencies
21+
run: pip install pre-commit
22+
23+
- name: Run Pre-commit Hooks
24+
run: pre-commit run --all-files
25+
926
tests:
1027
runs-on: ubuntu-latest
1128
strategy:

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- id: check-yaml
8+
- id: check-json
9+
- id: pretty-format-json
10+
args: [ --autofix ]
11+
- id: check-merge-conflict
12+
- id: check-symlinks
13+
- id: detect-private-key
14+
15+
- repo: https://github.com/crate-ci/typos
16+
rev: v1.26.8
17+
hooks:
18+
- id: typos

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Contribution in the form of [PRs] are welcome.
44

5-
Why We Are No Longer Accepting Public Issues
5+
Why We Are No Longer Accepting Public Issues
66
After careful consideration, we’ve decided to discontinue accepting issues via GitHub Issues for our public repositories.
77

88
Here’s why:

ChangeLog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [unreleased] - 2024-11-01
9+
### Added
10+
- Added pre-commit hooks and Github CI action for code formatting and linting.
11+
812
## [v0.3.11] - 2024-11-01
913
### Fixed
1014
- Deprecation warning for `datetime.utcnow()`
@@ -74,9 +78,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7478

7579
## [v0.3.1] - 2019-08-07
7680
### Fixed
77-
- Fixed an issue where the `DataApi` class's `results_iter` method would return no data
81+
- Fixed an issue where the `DataApi` class's `results_iter` method would return no data
7882
when receiving responses from Data API endpoints that set the "`data`" field of the
79-
response to an object (like the [itembank/questions endpoint](https://reference.learnosity.com/data-api/endpoints/itembank_endpoints#getQuestions)
83+
response to an object (like the [itembank/questions endpoint](https://reference.learnosity.com/data-api/endpoints/itembank_endpoints#getQuestions)
8084
when `item_references` is included in the request).
8185

8286
## [v0.3.0] - 2019-06-17

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center"><img width="50%" height="50%" src="https://github.com/Learnosity/learnosity-sdk-python/blob/master/docs/images/image-logo-graphic.png?raw=true"></p>
22
<h1 align="center">Learnosity SDK - Python</h1>
3-
<p align="center">Everything you need to start building your app in Learnosity, with the Python programming language.<br>
3+
<p align="center">Everything you need to start building your app in Learnosity, with the Python programming language.<br>
44
(Prefer another language? <a href="https://help.learnosity.com/hc/en-us/sections/360000194318-Server-side-development-SDKs">Click here</a>)<br>
55
An official Learnosity open-source project.</p>
66

@@ -72,7 +72,7 @@ Then, if you're following the tutorial on this page, also run:
7272
pip install learnosity_sdk[quickstart]
7373

7474
### **Alternative method 1: download the zip file**
75-
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.
75+
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.
7676

7777
Note: after installation, run this command in the SDK root folder:
7878

@@ -163,7 +163,7 @@ host = "localhost"
163163
port = 8000
164164
```
165165

166-
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.
166+
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.
167167

168168
``` python
169169
items_request = {
@@ -252,10 +252,10 @@ The call to `init()` returns an instance of the ItemsApp, which we can use to pr
252252
The Jinja template is rendered by the following line, which will bring in those variables.
253253

254254
``` python
255-
response = template.render(name='Standalone Assessment Example', generated_request=generated_request)
255+
response = template.render(name='Standalone Assessment Example', generated_request=generated_request)
256256
```
257257

258-
There is some additional code in [standalone_assessment.py](docs/quickstart/assessment/standalone_assessment.py), which runs Python's built-in web server.
258+
There is some additional code in [standalone_assessment.py](docs/quickstart/assessment/standalone_assessment.py), which runs Python's built-in web server.
259259

260260
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.
261261

@@ -271,7 +271,7 @@ See a more detailed breakdown of all the SDK features, and examples of how to us
271271
### **Additional quick start guides**
272272
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:
273273
* [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
274-
* [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.
274+
* [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.
275275

276276
### **Learnosity demos repository**
277277
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.
318318
[(Back to top)](#table-of-contents)
319319

320320
## Further reading
321-
Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites:
321+
Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites:
322322

323323
* [help.learnosity.com](http://help.learnosity.com/hc/en-us) -- general help portal and tutorials,
324324
* [reference.learnosity.com](http://reference.learnosity.com) -- developer reference site, and

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ print(signed_request)
292292
```
293293

294294
## Further reading
295-
Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites:
295+
Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites:
296296
<ul>
297297
<li><a href="http://help.learnosity.com">help.learnosity.com</a> -- general help portal and tutorials,
298298
<li><a href="http://reference.learnosity.com">reference.learnosity.com</a> -- developer reference site, and
299299
<li><a href="http://authorguide.learnosity.com">authorguide.learnosity.com</a> -- authoring documentation for content creators.
300300
</ul>
301301

302-
Back to [README.md](README.md)
302+
Back to [README.md](README.md)

docs/quickstart/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# The consumerKey and consumerSecret are the public & private
22
# security keys required to access Learnosity APIs and
33
# data. Learnosity will provide keys for your own private account.
4-
# Note: The consumer secret should be in a properly secured credential store,
5-
# and *NEVER* checked into version control.
4+
# Note: The consumer secret should be in a properly secured credential store,
5+
# and *NEVER* checked into version control.
66
# The keys listed here grant access to Learnosity's public demos account.
77

88
consumer_key = 'yis0TYCu7U9V4o7M'

learnosity_sdk/request/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def generate_signature(self) -> str:
130130
vals = []
131131

132132
# Add each valid security field.
133-
# The order is signifcant.
133+
# The order is significant.
134134
for key in self.security_keys:
135135
if key in self.security:
136136
vals.append(self.security[key])

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
]
2020

2121
TEST_REQUIRES = [
22+
'pre-commit',
2223
'pytest >=4.6.6',
2324
'pytest-cov >=2.8.1',
2425
'pytest-subtests',

0 commit comments

Comments
 (0)