Skip to main content

Python Build and Test

Python Package Exercise

Package Description

As seen on the PyPI website here, our package is intended to mimic student and professor email responses in a university class. Specifically, our functions give representative samples of student excuses and apologies based on various personal factors (the student's grade, how professional the student seeks seek to be, etc.), and professor decisions based on their own personal factors (how "sympathetic" they seek to be, etc.).

Installation

We require Python 3.11 or greater. We do not require any environment or database variables. Install the package using pip:

pip install realesagent 

Alternatively, if the above fails due to multiple python installations, use python -m pip install realesagent.
To use the package in your program, add the following to your import statements at the top of the program:

import realesagent 

As expected, you can also work directly in the interpreter:

>>> import realesagent

Usage

Every function can be imported from its module or straight from the package:

from realesagent import excuses            # module style: excuses.generate_excuse(...)
from realesagent import generate_excuse    # direct style: generate_excuse(...)

For a program that uses every function, see demos/example.py.


Student functions

Measure how desperate a student is, and turn the honest truth into professional language.

student.desperation_level(grade, hours_until_deadline, missing_assignments)

Calculates a desperation score from 1 (calm) to 10 (panic) based on the student's situation.

  • grade (int or float, 0–100): the student's current grade. Lower grades raise the score.
  • hours_until_deadline (int or float): hours until the deadline. 48 or fewer raises the score; 0 or below (already late) raises it most.
  • missing_assignments (int, 0 or more): number of missing assignments. Each adds 1 point, up to 3.

Returns: int from 1 to 10.

Raises:

  • TypeError if grade or hours_until_deadline is not a number, or missing_assignments is not an integer.
  • ValueError if grade is outside 0–100, a number is infinite or NaN, or missing_assignments is negative.
>>> from realesagent import student
>>> student.desperation_level(grade=90, hours_until_deadline=36, missing_assignments=7)
6

student.professionalize(truth)

Rewrites an honest explanation as a formal-sounding one. It recognizes oversleeping, forgetting, procrastinating, internet/Wi-Fi problems, and the dog eating your homework. Anything else gets a generic formal statement.

  • truth (str): what actually happened. Extra whitespace is ignored.

Returns: str, the professional version.

Raises:

  • TypeError if truth is not a string.
  • ValueError if truth is empty or only whitespace.
>>> student.professionalize(truth="My internet connectivity failed and I was too lazy to do anything about it.")
'I experienced an unexpected interruption to my digital connectivity.'
>>> student.professionalize(truth="I was at a concert.")
'I wish to formally report the following circumstance: "I was at a concert.". I respectfully request your consideration while I address this matter.'

Excuses functions

Generate excuses, grade requests, and apologies. generate_excuse and grade_beg pick a message at random, so your output may differ from the examples.

excuses.generate_excuse(assignment)

Returns a random excuse for not finishing an assignment. Some excuses mention the assignment by name.

  • assignment (str): the name of the assignment.

Returns: str, one randomly chosen excuse.

>>> from realesagent import excuses
>>> print(excuses.generate_excuse(assignment="Web Development Project"))
I was dealing with a family emergency. The family member was me, and the emergency was Web Development Project.

excuses.grade_beg(current_grade, desired_grade, professor_name)

Writes a complete email asking a professor to raise your grade, with a randomly chosen plea in the middle.

  • current_grade (int or float): your current grade, shown as a percentage.
  • desired_grade (int or float): the grade you're hoping for.
  • professor_name (str): the professor's name for the greeting.

Returns: str, the full email.

>>> email = excuses.grade_beg(current_grade=70, desired_grade=100, professor_name="John Smith")
>>> print(email)
Dear Professor John Smith,

I hope you are doing well. I am writing regarding my current grade of 70%.

I humbly ask that you consider the possibility that my grade is simply a passing grade experiencing a difficult time.

I was hoping you might consider adjusting my grade to 100%. I completely understand if this is not possible, but I figured it was worth one final attempt before I start looking into alternative career paths.

Thank you for your time, patience, and continued tolerance of my academic journey.

Best regards,
A Student Who Is This Close

excuses.apology_multiplier(email, desperation)

Adds an apology to the start of an email. The higher the desperation, the more dramatic the apology.

  • email (str): any message to put the apology in front of.
  • desperation (int, 1–10): how intense the apology is. Values below 1 are treated as 1, and above 10 as 10.

Returns: str, the apology, a blank line, then the original email.

>>> print(excuses.apology_multiplier(email="Can I have an extension?", desperation=7))
I sincerely, deeply, emotionally, and spiritually apologize. I have disappointed myself, my family, my ancestors, and possibly the entire academic community.

Can I have an extension?

Emails functions

Write subject lines and extension requests whose tone matches how bad the situation is.

emails.subject_line(situation, urgency)

Creates an email subject line that gets more dramatic as urgency rises.

  • situation (str): what the email is about.
  • urgency (int, 1–5): 1 is a casual question, 5 is a full emergency.

Returns: str, the subject line, or "Invalid urgency level" if urgency is not 1–5.

>>> from realesagent import emails
>>> emails.subject_line(situation="the midterm", urgency=1)
'Quick Question About the midterm'
>>> emails.subject_line(situation="the midterm", urgency=5)
'PLEASE READ BEFORE I BECOME A CAMPUS URBAN LEGEND: the midterm'

emails.extension_request(days_late, professor_name)

Writes an extension request email. The message changes depending on how late the assignment is: on time (0), 1–2 days, 3–5 days, 6–10 days, or more than 10.

  • days_late (int, 0 or more): how many days past the deadline.
  • professor_name (str): the professor's name for the greeting.

Returns: str, the full email.

Raises: ValueError if days_late is negative or professor_name is empty.

>>> print(emails.extension_request(days_late=3, professor_name="Jacob Williams"))
Dear Professor Jacob Williams,

I realize this assignment was due several days ago. I've spent those days reflecting on my choices rather than making better ones.

Best,
A Student With Excellent Intentions

Responses functions

Simulate how a professor might reply to your email.

responses.professor_reply(email, tone="strict")

Generates a professor's reply that quotes your message and responds in the chosen tone.

  • email (str): the student's message. Extra whitespace is collapsed.
  • tone (str, default "strict"): one of "strict", "sympathetic", or "sarcastic".

Returns: str, the professor's reply.

Raises:

  • TypeError if email or tone is not a string.
  • ValueError if email is empty or tone is not one of the three options.
>>> from realesagent import responses
>>> informal_email = "Yo prof, I have a C rn but I need an A to graduate. Can you help a brother out. Thanks man."
>>> print(responses.professor_reply(email=informal_email))
Dear Student,

Regarding your message: "Yo prof, I have a C rn but I need an A to graduate. Can you help a brother out. Thanks man."

As stated in the syllabus, the course policies still apply.

Best,
Your Fictional Professor
>>> print(responses.professor_reply(email=informal_email, tone="sarcastic"))
Dear Student,

Regarding your message: "Yo prof, I have a C rn but I need an A to graduate. Can you help a brother out. Thanks man."

A remarkable plot twist. Unfortunately, the syllabus has declined to rewrite itself.

Best,
Your Fictional Professor

Contribute as a Developer

Prerequisites

pip install pipenv

If pipenv isn't recognized afterward (common on Windows), replace pipenv with python -m pipenv in every command below.

Set up the project

Clone the repository and move into it:

git clone https://github.com/software-students-fall2026/python-package-exercise-realesagent.git
cd python-package-exercise-realesagent

Create the virtual environment and install all dependencies, including the dev tools (pytest, build, twine):

pipenv install --dev

This also installs realesagent itself in editable mode, so changes you make in src/realesagent/ take effect immediately without reinstalling.

No environment variables, database, or secret configuration files are needed.

Run the tests

pipenv run pytest

To run a single test file:

pipenv run pytest tests/test_emails.py

Run the example program

pipenv run python demos/example.py

Build the package

pipenv run python -m build

This creates a .whl and a .tar.gz file in the dist/ folder.

Contribution workflow

  1. Pull the latest main:
    git checkout main
    git pull
    
  2. Create a feature branch:
    git checkout -b your-feature-name
    
  3. Make your changes, add tests for them, and make sure pipenv run pytest passes.
  4. Commit and push your branch:
    git add .
    git commit -m "Describe your change"
    git push -u origin your-feature-name
    
  5. Open a pull request into main. Set the base repository to software-students-fall2026/python-package-exercise-realesagent, not the instructor's original repository.
  6. GitHub Actions automatically builds the package and runs the tests on two Python versions. Ask a teammate to review the code and run the tests locally.
  7. Once approved and passing, merge the pull request and delete the feature branch.

Publish a new version (maintainers only)

  1. Increase the version number in pyproject.toml. PyPI rejects versions that already exist.
  2. Delete the old dist/ folder, then rebuild:
    pipenv run python -m build
    
  3. Upload to PyPI:
    pipenv run twine upload dist/*
    
    When prompted, use __token__ as the username and your PyPI API token as the password.

Authors

This project was completed by Amitav Narayan (github), Nihal Sundari (github), Nishika Gorla (github), and Asritha Pannem(github).

Metadata

Release files for realesagent 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for realesagent 0.1.0
File Size Uploaded Provenance Actions
realesagent-0.1.0.tar.gz 26.9 kB Without provenance Details for realesagent-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for realesagent 0.1.0
File Interpreter ABI Platform Actions
realesagent-0.1.0-py3-none-any.whl Python 3 none any Details for realesagent-0.1.0-py3-none-any.whl

Total release size: 49.8 kB

Release files / realesagent-0.1.0.tar.gz

Download URL realesagent-0.1.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a872a0b66f2cf32d6fce40e37fc3046466e3c476f06c4a05dc6b96ba1adb45b0
BLAKE2b-256 checksum
How to use checksums
a8135558f5bcae5d5a1a64c04f1132b6fef1aecaa738286b18c3f79f61ed3f42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / realesagent-0.1.0-py3-none-any.whl

Download URL realesagent-0.1.0-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ce5828b505c9c81e6b207c17e03251b4f19cf01cb0f46a54ec0848bd49b5bf
BLAKE2b-256 checksum
How to use checksums
e599431ec2e6e4e680223dec423e309e0cb573bfaf26f632f8c1c1456c2c1b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for realesagent 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page