Skip to content

chore, docs: code formatting, README.md - #64

Merged
fmcubium merged 7 commits into
ufosc:mainfrom
anthisse:chore/code-formatting
Jun 18, 2026
Merged

fmcubium merged 7 commits into
ufosc:mainfrom
anthisse:chore/code-formatting

Conversation

@anthisse

Copy link
Copy Markdown
Collaborator

This pull request contains some chores to tidy up that backend and make it easier to understand. In more detail, it streamlines the README.md, adds type hints, and adds some tooling to the requirements.txt to make local LSPs run more effectively.

anthisse added 4 commits June 14, 2026 15:51
This commit adds ruff as a dependency to the project and formats the
code according to the rules in `backend/pyproject.toml`. It also allows
for installs to be done using either `uv` or `pip` via `(uv) pip install
-r backend/requirements.txt`, which should help cut down on the length of
the install process.
A lot of the backend documentation in README.md was similar for
different operating systems. This commit combines these similar lines
to make the README.md a little more clear for new users. It also
shows how to integrate uv` into our backend.
It's easier to get an LSP to pick up on what types variables and
function parameters are supposed to be if there's type-hinting aplenty
in the repo. This commit adds type hints to functions, global variables,
and some local variables where they're not immediately obvious. Future
commits should try to have type-hinting where possible and reasonable.
Some types don't want to statically resolve with just Pylance. The extra
django stub dependencies allow for the LSP to more consistently
understand which types are which. This should allow for fewer syntax
errors when building in the future.
@anthisse
anthisse requested a review from fmcubium June 15, 2026 00:48
Apparently, pytest-django wants the parameters to be named "db" instead
of anything. This reverts instances of preceeding underscores from the
parameter lists of functions in tests.py to resolve this issue.
This was linked to issues Jun 15, 2026


# serializers are cool because they allow you to skip having to deal with the model constructors
User = get_user_model()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django needs this line to avoid any conflicts when loading the default user model

Comment thread backend/quickstart/serializers.py
Comment thread backend/quickstart/serializers.py Outdated

def create(self, validated_data):
return User.objects.create_user(**validated_data) # hashes passwords
extra_kwargs = {"password": {"write_only": True, "style": {"input_type": "password"}}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New commit adds a trailing comma to get ruff to format as requested

@@ -1,40 +1,42 @@
from .models import Task
from rest_framework import serializers
from django.contrib.auth import get_user_model

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the django.contrib.auth import there

See below comment on Line 7

@@ -1,153 +1,142 @@
# Some tests created with aid from Gemini

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably still mention that some of the tests were LLM generated to be honest

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is entirely necessary, but mentioning is fine with me.

Comment thread backend/quickstart/tests.py
api_client: APIClient,
test_user: StudyUser,
test_task: Task,
test_username: str,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing ,

def test_task_belongs_to_requesting_user(
self,
api_client: APIClient,
test_user: StudyUser,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing ,

self,
api_client: APIClient,
test_user: StudyUser,
other_user: StudyUser,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing ,

Comment thread .gitignore

# postman
.postman/
postman/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I'm planning on using Insomnia instead of Postman right now

@anthisse anthisse Jun 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, but there's no harm in having Postman gitignore stuff here for right now. Once you set up Insomnia add it to the .gitignore

Fixes some requested changes requested in PR 64.
@anthisse
anthisse requested a review from fmcubium June 16, 2026 05:46
@fmcubium fmcubium added the documentation Improvements or additions to documentation label Jun 17, 2026
Comment thread backend/quickstart/serializers.py Outdated
"reward": 50,
"description": "Finish algebra 1",
"due_date": "2029-12-31"
"due_date": "2029-12-31",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll still break the JSON, even if it's not within the quotes. Trailing commas are disallowed in JSON objects, see this

def test_create_task_missing_due_date(
self,
api_client: APIClient,
test_user: StudyUser,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my response above

Co-authored-by: Andres <84483578+fmcubium@users.noreply.github.com>

@fmcubium fmcubium left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An internal decision on formatting was made and I was also mistaken on Django serializers. LGTM

@fmcubium
fmcubium merged commit 8063804 into ufosc:main Jun 18, 2026
1 of 2 checks passed
anthisse pushed a commit to anthisse/Studygatchi that referenced this pull request Jul 26, 2026
chore, docs: code formatting, README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code formatting streamline setup process with requirements.txt

2 participants