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

Use pre-commit for linting #3177

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ jobs:
- name: Test Python types (mypy)
shell: bash
run: poetry run mypy apps
- name: Python code style (black)
- name: Python code style (ruff)
shell: bash
run: poetry run black apps --check
- name: Python code style (pylint)
shell: bash
run: poetry run pylint $(git ls-files '*.py')
run: poetry run ruff check apps
- name: validate that Test Course Json files are up to date
run: |
poetry install --no-interaction
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ localData/
# Courses
/apps/web/src/courses/*-*
/courses/*-*

17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-json
exclude: .*?/tsconfig.json
- id: check-ast
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,3 @@ specific requirements.
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<a href="https://librelingo.app/dev/"><img src="https://img.shields.io/badge/List_of_courses-librelingo.app/dev-darkcyan" /></a>
<a href="https://librelingo.app/docs/"><img src="https://img.shields.io/badge/Documentation-librelingo.app/docs-darkcyan" /></a>
<a href="https://github.com/orgs/LibreLingo/projects/1/views/1"><img src="https://img.shields.io/badge/Roadmap-github.com-darkcyan" /></a>


</p>
<hr/>

Expand Down Expand Up @@ -108,7 +108,7 @@ You can use librelingo-yaml-loader to load YAML-based LibreLingo courses in your
```python
from librelingo_yaml_loader import yaml_loader

course = yaml_loader.load_course("./path/to/my/course")
course = yaml_loader.load_course("./path/to/my/course")
```
`load_course` returns a [Course()](https://github.com/kantord/LibreLingo/blob/main/apps/librelingo_yaml_loader/librelingo_yaml_loader/data_types.py) object.

Expand Down Expand Up @@ -170,7 +170,7 @@ Go through the dev docs [here](https://librelingo.app/docs/).

Still got questions? Our Matrix/FreeNode IRC channel is `#LibreLingo`, join the dev community there and feel free to ask anything.
* Matrix: [`#LibreLingo`](https://app.element.io/#/room/#space-librelingo:matrix.org) on `matrix.org`
* IRC: connect to `irc.freenode.net` with your favourite client and join `#LibreLingo`
* IRC: connect to `irc.freenode.net` with your favourite client and join `#LibreLingo`

#### are you a linguaphile?
Learning new language is an awesome experience right? If you wanna let others experience that too, make a course on LibreLingo! Get started [here](https://github.com/kantord/LibreLingo/tree/main/docs/courses).
Expand Down Expand Up @@ -346,4 +346,3 @@ LibreLingo is licensed under the AGPL-3.0 license. In addition, course content a

## Donate
Help us to keep going

4 changes: 2 additions & 2 deletions apps/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN mkdir /usr/local/nvm
ENV NVM_DIR /usr/local/nvm

# Setup to allow using poetry
ENV PATH="/root/.local/bin:$PATH"
ENV PATH="/root/.local/bin:$PATH"

# Make sure you have the latest version of things
RUN apt update
Expand Down Expand Up @@ -47,7 +47,7 @@ WORKDIR /LibreLingo
RUN source $NVM_DIR/nvm.sh && nvm install 14 && nvm use 14 && yarn install

# Install poetry
RUN curl -sSL https://install.python-poetry.org | python -
RUN curl -sSL https://install.python-poetry.org | python -

# Install Python dependencies
RUN poetry install
Expand Down
2 changes: 1 addition & 1 deletion apps/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Docker Hub](https://hub.docker.com/r/librelingo/librelingo)
## Usage
The LibreLingo container may take a little while too start up, especially if it is the first time running the container. You can follow the logs for the contaienr by running
The LibreLingo container may take a little while too start up, especially if it is the first time running the container. You can follow the logs for the contaienr by running
```
docker container logs -f LibreLingo
```
Expand Down
6 changes: 3 additions & 3 deletions apps/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ if [[ "${GIT_REPO}" == "TRUE" ]]; then
fi
fi
cd /LibreLingo
yarn set version classic
yarn set version classic
yarn install --frozen-lockfile
poetry install
cd /LibreLingo/apps/librelingo_yaml_loader
poetry install
cd /LibreLingo/apps/librelingo_json_export
poetry install
cd /LibreLingo/apps/librelingo_json_export
poetry install
yarn exportAllCourses # Exports all courses in /LibreLingo/courses
yarn web dev # Runs LibreLingo
2 changes: 1 addition & 1 deletion apps/librelingo-standalone-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ func main() {

fmt.Printf("Running on: %s", addr)
http.ListenAndServe(addr, dir)
}
}
2 changes: 1 addition & 1 deletion apps/librelingo_audios/librelingo_audios/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.3.0" # Do not edit before merge to 'main'

from librelingo_audios.functions import list_required_audios
from librelingo_audios.functions import list_required_audios # noqa: F401
2 changes: 1 addition & 1 deletion apps/librelingo_audios/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def mock_index_entry():
def terminal(tmp_path, capsys):
def assert_output_matches(set_of_messages):
assert set(set_of_messages) == {
l for l in capsys.readouterr().out.split("\n") if l != ""
line for line in capsys.readouterr().out.split("\n") if line != ""
}

return SimpleNamespace(
Expand Down
1 change: 0 additions & 1 deletion apps/librelingo_fakes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ number(max_value=10000)

Returns a 'random' non-negative integer.
It is NOT cryptographically-secure.

2 changes: 1 addition & 1 deletion apps/librelingo_fakes/librelingo_fakes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from librelingo_fakes.fakes import *
from librelingo_fakes.fakes import * # noqa: F403

__version__ = "3.0.1" # Do not edit before merge to 'main'
1 change: 0 additions & 1 deletion apps/librelingo_json_export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ from librelingo_json_export.export import export_course
course = load_course("./courses/french-from-english")
export_course("./apps/web/src/courses/french-from-english", course)
```

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Export LibreLingo courses in the JSON format used by the web app
"""

import librelingo_json_export.export
import librelingo_json_export.export # noqa: F401

__version__ = "0.10.1" # Do not edit before merge to 'main'
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@
"id": "379dca1c8ae9",
"levels": 2,
},
str(
Path("./output/introduction/hello.md")
): """# Lorem Ipsum
str(Path("./output/introduction/hello.md")): """# Lorem Ipsum

## Dolor sit amet

Expand Down
1 change: 0 additions & 1 deletion apps/librelingo_types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,3 @@ class PhraseIdentity(namedtuple("PhraseIdentity", ["text", "source"]))

This is the set of information that identifies a phrase as 'the same'. If any
of these things change, the phrase will be seen as 'new' and re-generated.

2 changes: 1 addition & 1 deletion apps/librelingo_types/librelingo_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Data types to be used in Python packages for LibreLingo
"""

from librelingo_types.data_types import *
from librelingo_types.data_types import * # noqa: F403

__version__ = "3.2.0" # Do not edit before merge to 'main'
1 change: 0 additions & 1 deletion apps/librelingo_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@ iterate_words(course: Course)
```

"Flatten" a course into a sequence of words

2 changes: 1 addition & 1 deletion apps/librelingo_utils/librelingo_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
to create Python software that works with LibreLingo courses.
"""

from librelingo_utils.utils import *
from librelingo_utils.utils import * # noqa: F403

__version__ = "2.6.1" # Do not edit before merge to 'main'
1 change: 0 additions & 1 deletion apps/librelingo_yaml_loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ def load_course(path: str)
```

Load a YAML-based course into a Course() object

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Load YAML-based LibreLingo courses in your Python project.
"""

from librelingo_yaml_loader.yaml_loader import load_course
from librelingo_yaml_loader.yaml_loader import load_course # noqa: F401

__version__ = "1.10.1" # Do not edit before merge to 'main'
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
}
},
"required": ["Module","Skills"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"required": [
"Word",
"Translation",
"Translation"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ Two-way-dictionary:
- source_3_b: target_3
- (I) eat: (yo) como
- (before_s) source_4 (after_s): (before_t) target_4 (after_t)

2 changes: 1 addition & 1 deletion apps/lluis/NewNavBar/NavBarItem.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div>
<div>
<slot />
</div>
2 changes: 0 additions & 2 deletions apps/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ if re.search(r'[^a-zA-Z0-9_.-]', img):
* but other than these words should be either in one or the other section.
* TODO: we might want to add a warning if the appear in both (that could be silenced by a flag)
* should find "mujer" in "la mujer" but not "mu" in "la mujer" maybe should indicate it is partial match


1 change: 0 additions & 1 deletion apps/tools/librelingo_tools/lili-search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def main():
course = load_course(course_path)
for module in course.modules:
for skill in module.skills:

# Word(
# in_target_language=['el chapeo', 'el chapeyo'],
# in_source_language=['the hat'],
Expand Down
1 change: 0 additions & 1 deletion apps/tools/librelingo_tools/templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
</table>

{% include 'central/footer.html' %}

1 change: 0 additions & 1 deletion apps/tools/librelingo_tools/templates/incl/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
<li {% if page == "source" %}class="is-active"{% endif %}><a href="{{ rel }}source.html">{{ course.source_language.name }}</a></li>
</ul>
</div>

4 changes: 2 additions & 2 deletions apps/tools/tests/test_test_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def assert_folders_are_identical(expected_path, actual_path):

if filename.endswith(".md"):
with open(os.path.join(actual_path, relpath)) as fh:
actual = fh.read()
actual = fh.read().strip()
with open(os.path.join(expected_path, relpath)) as fh:
expected = fh.read()
expected = fh.read().strip()
assert actual == expected, relpath
continue

Expand Down
2 changes: 1 addition & 1 deletion apps/web/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
}
1 change: 0 additions & 1 deletion apps/web/cypress/integration/cancelButton.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Feature: Cancel button in a practice session
Given I open "/course/test-2/skill/animals"
And I click "Cancel"
Then I should be on "/course/test-2"

2 changes: 1 addition & 1 deletion apps/web/cypress/integration/chips.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Chips challenge
Scenario: Using the mini-dictionary
Given I open "/course/test-1/skill/chips-test-0?testChallenge=c3f7fcb9c86c"
Then words with definitions have tooltips

Scenario: Submitting an incorrect solution
Given I open "/course/test-1/skill/chips-test-0?testChallenge=5000997897bb"
And I click "estás"
Expand Down
2 changes: 0 additions & 2 deletions apps/web/cypress/integration/dev-typography.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ Feature: Typography Examples
Scenario: Opening the typography examples
Given I open "/dev-typography"
Then the dev-typography page looks correct


2 changes: 1 addition & 1 deletion apps/web/cypress/integration/fanfareScreen.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Fanfare screen

A screen to display to the user when a practice session is successfully completed

Scenario: Getting to the fanfare screen
Expand Down
1 change: 0 additions & 1 deletion apps/web/cypress/integration/gistPreview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Feature: Previewing courses using GitHub Gists
Scenario: Opening a skill introduction from a GitHub Gist directly
Given I open "/course/preview/skill/gist/introduction?skillName=animals&gistId=2428349a05d81f96b2311c2749ea5c6d"
Then I see a "Practice Animals" button

2 changes: 1 addition & 1 deletion apps/web/cypress/integration/homepageButton.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Homepage button
When I open "/course/test-1/skill/animals/introduction"
And I click on link "logo"
Then I should be on "/course/test-1/"

Scenario: I'm on skill page
When I open "/course/test-1/skill/animals"
And I click on link "logo"
Expand Down
4 changes: 1 addition & 3 deletions apps/web/cypress/integration/introductionPage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ Feature: Skill introduction page
Scenario: Practicing the skill from the introduction page
When I open "/course/test-1/skill/animals/introduction"
Then I read "Introduction to animals"
When I click "Practice Animals"
When I click "Practice Animals"
Then I should be on "/course/test-1/skill/animals"


4 changes: 2 additions & 2 deletions apps/web/cypress/integration/listening.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Feature: Listening exercise

A challenge type where the user has to type the phrase they hear on an audio recording

Scenario: Getting a listening challenge
Expand Down Expand Up @@ -32,7 +32,7 @@ Feature: Listening exercise
Then I read "Incorrect solution"
And I read "Correct answer: perro"
And I see a "Continue" button

Scenario: Submitting correct answer
Given I open "/course/test-1/skill/listening-test-0?testChallenge=cd183d15d4d1"
And I type "perro"
Expand Down
6 changes: 3 additions & 3 deletions apps/web/cypress/integration/shortInput.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Short text input challange
And I see an input field
And the input field is focused
And the input field has a "Type your answer…" placeholder

Scenario: Virtual keyboard for special characters
Given I open "/course/test-1/skill/short-input-test-0?testChallenge=14fc2ae4fb35"
Then I see a virtual keyboard with 16 keys
Expand All @@ -32,15 +32,15 @@ Feature: Short text input challange
Then I see the challenge panel
And I see a "Skip" button
And I see a "Submit" button

Scenario: Submitting incorrect answer
Given I open "/course/test-1/skill/short-input-test-0?testChallenge=14fc2ae4fb35"
And I type "asdfg"
And I click "Submit"
Then I read "Incorrect solution"
And I read "Correct answer: perro"
And I see a "Continue" button

Scenario: Submitting correct answer
Given I open "/course/test-1/skill/short-input-test-0?testChallenge=14fc2ae4fb35"
And I type "perro"
Expand Down
2 changes: 0 additions & 2 deletions apps/web/cypress/integration/signUpForm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,3 @@ Feature: Sign up form
And I am not really calling the registration API
And I click the "Sign up" button
Then I read "You have to accept the agreements."


1 change: 0 additions & 1 deletion apps/web/cypress/integration/skip.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Feature: Skipping a challenge
Given I open "/course/test-1/skill/chips-test-0?testChallenge=5000997897bb"
When I click "Skip"
Then I should have progressed

2 changes: 1 addition & 1 deletion apps/web/src/courses/test-1/challenges/animals.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,4 @@
"group": "dc51787e55a3"
}
]
}
}
2 changes: 1 addition & 1 deletion apps/web/src/courses/test-1/challenges/cards-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@
"group": "ebba45a45a9a"
}
]
}
}
Loading
Loading