Skip to content

Commit

Permalink
modify readme and contributing for Ruff addition+ run ruff formatter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdavham authored Aug 10, 2024
1 parent 48423c5 commit 879a141
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
13 changes: 9 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,23 @@ Now you're ready to make changes to `src/fsrs` and see your changes reflected im

This project follows [semantic versioning](https://semver.org/), so please make sure to increment the version number in [pyproject.toml](pyproject.toml) when contributing new code.

### Format and test
### Lint, format and test

Py-FSRS follows the [black](https://github.com/psf/black) code formatting style and uses [pytest](https://docs.pytest.org) to run its tests. In order for your contribution to be accepted, your code must be properly formatted and be able to pass the tests.
Py-FSRS uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting and uses [pytest](https://docs.pytest.org) to run its tests. In order for your contribution to be accepted, your code must pass linting/formatting checks and be able to pass the tests.

You can install these packages with
```
pip install black pytest
pip install ruff pytest
```

Lint your code with:
```
ruff check --fix
```

Format your code with:
```
black .
ruff format
```

Run the tests with:
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div align="center" style="text-decoration: none;">
<a href="https://pypi.org/project/fsrs/"><img src="https://img.shields.io/pypi/v/fsrs"></a>
<a href="https://github.com/open-spaced-repetition/py-fsrs/blob/main/LICENSE" style="text-decoration: none;"><img src="https://img.shields.io/badge/License-MIT-brightgreen.svg"></a>
<a href="https://github.com/psf/black" style="text-decoration: none;"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
</div>
<br />

Expand Down Expand Up @@ -177,8 +177,4 @@ Rating.Easy # recall; perfect response

## Contribute

Checkout [CONTRIBUTING](CONTRIBUTING.md) to help improve Py-FSRS!

## License

Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
Checkout [CONTRIBUTING](CONTRIBUTING.md) to help improve Py-FSRS!
6 changes: 3 additions & 3 deletions src/fsrs/fsrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def __init__(
def review_card(
self, card: Card, rating: Rating, now: Optional[datetime] = None
) -> tuple[Card, ReviewLog]:

scheduling_cards = self.repeat(card, now)

card = scheduling_cards[rating].card
review_log = scheduling_cards[rating].review_log

return card, review_log

def repeat(self, card: Card, now: Optional[datetime] = None) -> dict[int, SchedulingInfo]:

def repeat(
self, card: Card, now: Optional[datetime] = None
) -> dict[int, SchedulingInfo]:
if now is None:
now = datetime.now(timezone.utc)

Expand Down
7 changes: 0 additions & 7 deletions tests/test_fsrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def print_scheduling_cards(scheduling_cards):


class TestPyFSRS:

def test_repeat(self):
f = FSRS()
f.p.w = (
Expand Down Expand Up @@ -73,7 +72,6 @@ def test_repeat(self):
assert ivl_history == [0, 5, 16, 43, 106, 236, 0, 0, 12, 25, 47, 85, 147]

def test_repeat_default_arg(self):

f = FSRS()

card_object = Card()
Expand All @@ -92,7 +90,6 @@ def test_repeat_default_arg(self):
assert time_delta.seconds > 500 # due in approx. 8-10 minutes

def test_datetime(self):

f = FSRS()
card = Card()

Expand All @@ -118,7 +115,6 @@ def test_datetime(self):
assert card.due >= card.last_review

def test_Card_serialize(self):

f = FSRS()

# create card object the normal way
Expand Down Expand Up @@ -158,7 +154,6 @@ def test_Card_serialize(self):
assert card.to_dict() != repeated_card.to_dict()

def test_ReviewLog_serialize(self):

f = FSRS()

card = Card()
Expand Down Expand Up @@ -204,7 +199,6 @@ def test_ReviewLog_serialize(self):
assert review_log.to_dict() != next_review_log.to_dict()

def test_review_card(self):

f = FSRS()
f.p.w = (
1.14,
Expand Down Expand Up @@ -260,7 +254,6 @@ def test_review_card(self):
assert ivl_history == [0, 5, 16, 43, 106, 236, 0, 0, 12, 25, 47, 85, 147]

def test_custom_scheduler_args(self):

f = FSRS(
w=(
1.14,
Expand Down

0 comments on commit 879a141

Please sign in to comment.