Skip to content

feat: repo polish – LICENSE, CI, tests, type hints, templates, Makefile - #4

Merged
icecold009 merged 2 commits into
mainfrom
copilot/improve-repo-appearance
Apr 25, 2026
Merged

feat: repo polish – LICENSE, CI, tests, type hints, templates, Makefile#4
icecold009 merged 2 commits into
mainfrom
copilot/improve-repo-appearance

Conversation

Copilot AI commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Adds everything needed to make this project look and function like a maintained, professional repo — resolves broken badge links, missing package in requirements, undocumented CLI behaviour, and zero test coverage.

Summary

Comprehensive repo hygiene pass: adds missing infrastructure (LICENSE, CI, tests, tooling) and fixes several silent correctness issues (missing face-recognition dep, --host flag that didn't work, duplicate/orphaned README content).

Type of Change

  • New feature
  • Refactor / code quality
  • Documentation update

Changes Made

Fixes (silent bugs / broken things)

  • requirements.txt — added face-recognition>=1.3.0; was absent, so pip install -r requirements.txt would fail at runtime
  • web_app.py — wired up --host/--port/--debug CLI args via argparse; README documented --host 0.0.0.0 but code hardcoded 127.0.0.1 and ignored all args
  • README.md — removed orphaned duplicate Future Enhancements bullets and stray Last Updated line stranded after </div>; replaced placeholder Screenshots code block with a proper table

New infrastructure

  • LICENSE — MIT; fixes broken badge link
  • .github/workflows/ci.yml — flake8 (E9/F-codes only) + pytest on push/PR to main; permissions: contents: read set explicitly
  • tests/ — 21 unit tests for AttendanceSystem and FaceAttendanceApp; use tmp_path fixtures, no camera/dlib required
  • Makefileinstall, run, run-cli, test, lint, clean
  • .github/ISSUE_TEMPLATE/ — bug report + feature request templates
  • .github/pull_request_template.md
  • CONTRIBUTING.md, CHANGELOG.md

Code quality

  • Type hints added to all public methods in attendance.py, face_attendance_app.py, web_app.py
  • Removed dead legacy script src/attendance_project.py
  • CI badge added to README

Testing

  • Existing tests pass (pytest tests/ -v)
  • New tests added for new functionality
  • Manually tested with webcam

Checklist

  • Code follows the project style (PEP 8, max line length 120)
  • README updated if behaviour changed
  • CHANGELOG.md updated under [Unreleased]

@icecold009
icecold009 marked this pull request as ready for review April 25, 2026 16:01
Copilot AI review requested due to automatic review settings April 25, 2026 16:01
@icecold009
icecold009 merged commit adf212b into main Apr 25, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR is a repo hygiene + correctness pass that adds CI/testing scaffolding, improves documentation, and fixes the web_app.py CLI flags so the documented --host/--port/--debug behavior works as advertised.

Changes:

  • Added GitHub Actions CI (flake8 + pytest) plus a Makefile and GitHub templates/docs (LICENSE/CONTRIBUTING/CHANGELOG).
  • Added initial unit test coverage for AttendanceSystem and FaceAttendanceApp.
  • Wired web_app.py to actually use --host/--port/--debug CLI arguments and added type hints across core modules.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
web_app.py Adds argparse CLI flags and return type annotations for Flask routes.
src/face_attendance_app.py Adds type hints; face-recognition-based core app logic.
src/attendance.py Adds type hints; attendance CSV persistence and history methods.
src/attendance_project.py Removes legacy script.
tests/conftest.py Makes src/ importable for tests.
tests/test_attendance.py Adds unit tests for AttendanceSystem CSV behavior.
tests/test_face_attendance_app.py Adds unit tests for non-camera flows of FaceAttendanceApp.
.github/workflows/ci.yml Adds CI workflow for lint + unit tests.
requirements.txt Adds missing face-recognition dependency.
README.md Fixes/cleans README content, updates screenshots section, updates host usage, adds CI badge.
Makefile Adds common developer commands (install/run/test/lint/clean).
LICENSE Adds MIT license file.
CONTRIBUTING.md Adds contribution and setup guidelines.
CHANGELOG.md Adds initial changelog following Keep a Changelog.
.github/pull_request_template.md Adds PR template.
.github/ISSUE_TEMPLATE/bug_report.md Adds bug report template.
.github/ISSUE_TEMPLATE/feature_request.md Adds feature request template.
Comments suppressed due to low confidence (2)

web_app.py:51

  • These route handlers are annotated as returning Response, but several branches return (jsonify(...), 400) / (jsonify(...), 500) tuples. For accurate typing (and to avoid misleading future changes), use Flask’s return type alias (e.g. flask.typing.ResponseReturnValue) or a union that includes the (Response, int) form.
def recognize() -> Response:
    """
    Handle face recognition on a frame.
    Expects:
        - frame: base64-encoded JPEG image
    Returns:
        - annotated_frame: base64-encoded JPEG with rectangles/labels
        - recognized_names: list of names detected in this frame
        - timestamp: server timestamp
    """
    try:
        data = request.get_json()
        frame_b64 = data.get('frame')
        
        if not frame_b64:
            return jsonify({'error': 'No frame provided'}), 400
        

src/attendance.py:81

  • get_person_attendance_history accepts a days parameter but it is currently unused, and the function silently swallows all CSV read errors with a bare except. Either implement the days filtering (e.g., based on the date in the filename) or remove the parameter; and prefer catching specific exceptions (and optionally logging) so real issues aren’t hidden.
    def get_person_attendance_history(self, name: str, days: int = 30) -> Optional[pd.DataFrame]:
        """Get attendance history for a person"""
        records = []
        
        # Search through attendance files
        for filename in os.listdir(self.attendance_path):
            if filename.endswith('.csv') and filename.startswith('Attendance_'):
                filepath = os.path.join(self.attendance_path, filename)
                try:
                    df = pd.read_csv(filepath)
                    person_records = df[df['Name'] == name]
                    if not person_records.empty:
                        records.append(person_records)
                except:
                    pass

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 3 to 6
import cv2
import numpy as np
import face_recognition
import os

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

face_recognition is imported at module import time, which means importing FaceAttendanceApp fails unless the heavy face-recognition/dlib stack is installed. This contradicts the new unit tests/CI intent (“no face_recognition required”) and will break the test job as written. Consider making face_recognition an optional/lazy import (e.g., import inside methods or behind a try/except) and ensure __init__/load_and_encode_faces can run (at least to create directories) without it, raising a clear runtime error only when recognition/enrollment is invoked.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
python-version: "3.11"

- name: Install test dependencies
run: pip install pytest pandas numpy opencv-python-headless Pillow

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

The test job installs a minimal dependency set but does not install face-recognition. Since src/face_attendance_app.py imports face_recognition at import time, pytest will fail during import. Either install the full runtime deps here (e.g., pip install -r requirements.txt) or adjust the application code/tests to avoid requiring face-recognition to import/run the unit tests.

Suggested change
run: pip install pytest pandas numpy opencv-python-headless Pillow
run: |
pip install -r requirements.txt
pip install pytest

Copilot uses AI. Check for mistakes.
Comment thread web_app.py
import numpy as np
from io import BytesIO
from flask import Flask, render_template, request, jsonify
from typing import Any

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

Any is imported but not used in this module. Removing unused imports helps keep the module surface small and avoids confusion during future refactors (especially since the flake8 config in CI won’t flag F401).

Suggested change
from typing import Any

Copilot uses AI. Check for mistakes.
@icecold009
icecold009 deleted the copilot/improve-repo-appearance branch September 1, 2026 15:35
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