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

timer: import submodules only and add tests #1075

Merged
merged 4 commits into from
Jan 12, 2025

Conversation

adbar
Copy link
Contributor

@adbar adbar commented Jan 10, 2025

Type of pull request:

  • Bug fix
  • Feature
  • Other

Description:

This PR updates the timer class to make the code more concise and adds tests.

Related Issues:

Addresses #920.

Checklist:

  • I have read and followed the contribution guidelines.
  • I have added necessary documentation (if applicable).
  • The changes pass all existing tests.

@adbar adbar changed the title timer: use import submodules only and add tests timer: import submodules only and add tests Jan 10, 2025
@adbar
Copy link
Contributor Author

adbar commented Jan 10, 2025

Does somebody know how to add slots to a class so that ruff accepts the code?

I also get TC002 errors in test_bot/test_model.py although I didn't modify the code there.

@MarkZH
Copy link
Collaborator

MarkZH commented Jan 10, 2025

Put the __slots__ declaration below the class's docstring.

Also, when you run ruff on your own machine, make sure you run it using the configuration file: ruff check --config rest_bot/ruff.toml (or with a \ in Windows).

@adbar
Copy link
Contributor Author

adbar commented Jan 11, 2025

@MarkZH Thanks for the suggestions, everything looks fine now.

test_bot/test_timer.py Outdated Show resolved Hide resolved
@MarkZH
Copy link
Collaborator

MarkZH commented Jan 12, 2025

For my own curiosity, what was your purpose for adding the __slots__ member to Timer?

@adbar
Copy link
Contributor Author

adbar commented Jan 12, 2025

@MarkZH "Slots are more efficient in terms of memory space and speed of access, and a bit safer than the default Python method of data access. " (Python Wiki)

@AttackingOrDefending AttackingOrDefending merged commit dc5524a into lichess-bot-devs:master Jan 12, 2025
23 checks passed
@adbar adbar deleted the timer_tests branch January 13, 2025 10:52
@adbar adbar mentioned this pull request Jan 13, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants