Skip to content

dev: add type hints to source code for better IDE support - #32

Open
NobleCoder69 wants to merge 7 commits into
ga4gh:mainfrom
NobleCoder69:dev/type-hints
Open

dev: add type hints to source code for better IDE support#32
NobleCoder69 wants to merge 7 commits into
ga4gh:mainfrom
NobleCoder69:dev/type-hints

Conversation

@NobleCoder69

@NobleCoder69 NobleCoder69 commented Mar 23, 2026

Copy link
Copy Markdown

Added type hints to src/main.py to improve IDE support and static analysis.

Changes:

  • Added return type annotations
  • Added attribute type annotations
  • Added Dict / List / Optional / Any typing
  • Improved code readability

This helps with mypy checks and better developer experience.
Closes #31

- Create examples/ directory with 3 sample GA4GH policy documents
- Add examples/DEMO.md with step-by-step instructions
- Create examples/run_demo.py script demonstrating full pipeline
- Demo processes 12 chunks and shows 3 sample compliance queries
- Fixes ga4gh#20
types-all includes types-pkg-resources which no longer exists on PyPI.
Since we're using --ignore-missing-imports, we don't need it anyway.
- Create .env.example with all required and optional variables
- Create ENV_SETUP.md with comprehensive setup instructions
- Add security best practices and common issues
- Fixes ga4gh#23
- Add lint.yml: Run pre-commit hooks on every PR
- Add tests.yml: Run pytest on multiple Python versions (3.8-3.12)
- Add format.yml: Auto-fix code quality issues and commit
- Add .github/workflows/README.md with workflow documentation
- Automated testing and linting on every PR
- Auto-fixes with PR comments
- Coverage reporting with Codecov
- Fixes ga4gh#24
Copilot AI review requested due to automatic review settings March 23, 2026 14:58

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 aims to improve developer ergonomics via Python type hints and introduces a full “code quality + CI” setup (formatting, linting, type checking) along with demo assets/docs for running the project.

Changes:

  • Added type annotations to src/main.py for improved IDE/static analysis support.
  • Introduced Black/Ruff/isort/mypy configuration plus pre-commit hooks.
  • Added GitHub Actions workflows, demo script, sample data, and supporting documentation.

Reviewed changes

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

Show a summary per file
File Description
src/main.py Adds type annotations to class attributes and method return types.
pyproject.toml Central config for Black/isort/Ruff/mypy.
examples/run_demo.py Adds an end-to-end demo script for sample policy documents.
examples/data/sample_consent_policy.txt Adds sample consent policy text for the demo.
examples/data/sample_privacy_policy.txt Adds sample privacy/security policy text for the demo.
examples/data/sample_genomic_framework.txt Adds sample genomic sharing framework text for the demo.
examples/DEMO.md Documents how to run the demo.
README.md Adds a “Code Quality” section describing the tooling.
ENV_SETUP.md Adds environment variable setup guide and .env usage notes.
CODE_QUALITY.md Adds code-quality tooling guide (Black/Ruff/isort/mypy/pre-commit).
.pre-commit-config.yaml Adds pre-commit hooks for formatting, linting, typing, and basic hygiene checks.
.gitignore Ignores venv/caches and .env.
.github/workflows/tests.yml Adds a multi-Python-version test workflow with coverage upload.
.github/workflows/lint.yml Adds a pre-commit-based lint workflow.
.github/workflows/format.yml Adds an auto-fix workflow that commits formatting/lint fixes back to the PR branch.
.github/workflows/README.md Documents the included GitHub Actions workflows.
.env.example Provides a template for required environment variables.

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

Comment thread examples/run_demo.py
@@ -0,0 +1,110 @@
#!/usr/bin/env python3

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The file starts with a UTF-8 BOM (the invisible character before the shebang). This can break the shebang on Unix-like systems (it won’t be recognized as an executable script). Please remove the BOM so the first bytes are exactly "#!/usr/bin/env python3".

Suggested change
#!/usr/bin/env python3
#!/usr/bin/env python3

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,52 @@
name: Tests

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

Line 1 contains a UTF-8 BOM (invisible character before name:). BOMs have caused YAML parsing issues in some tooling; removing it avoids flaky workflow loading.

Suggested change
name: Tests
name: Tests

Copilot uses AI. Check for mistakes.
Comment thread CODE_QUALITY.md
Comment on lines +7 to +19
### Black
**Purpose:** Automatic code formatter
- Enforces consistent code style
- Line length: 100 characters
- Run: \lack src/\

### Ruff
**Purpose:** Fast Python linter
- Checks PEP 8 compliance
- Catches common errors
- Fixes issues automatically
- Run: \uff check --fix src/\

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The command examples contain control characters (backspace / carriage return), causing tool names like black/ruff to render incorrectly (e.g., \b lack, \r uff). Please remove these control characters and format commands with backticks or fenced code blocks so the instructions are accurate.

Copilot uses AI. Check for mistakes.
Comment thread examples/run_demo.py
Comment on lines +36 to +38
with open(f) as file:
content = file.read()
lines = len(content.split("\n"))

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

Files are opened without specifying an encoding. On Windows (or non-UTF-8 locales) this can raise decode errors. Prefer encoding="utf-8" (and optionally newline="") when reading the sample text files.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,16 @@
GA4GH CONSENT POLICY - SAMPLE EXCERPT (POL 002 v2.0)

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

This sample text file starts with a UTF-8 BOM (invisible character before the first letter). If these files are later embedded/parsed, the BOM becomes part of the text and can affect chunking/search. Consider saving the file as UTF-8 without BOM.

Suggested change
GA4GH CONSENT POLICY - SAMPLE EXCERPT (POL 002 v2.0)
GA4GH CONSENT POLICY - SAMPLE EXCERPT (POL 002 v2.0)

Copilot uses AI. Check for mistakes.
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ Linting failed. Please run \pre-commit run --all-files\ locally and push fixes.'

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The PR comment body contains backslashes around the command (\pre-commit run --all-files\), which will render as literal backslashes. Use Markdown inline code formatting (backticks) so the command is copy/pastable and renders correctly.

Suggested change
body: '⚠️ Linting failed. Please run \pre-commit run --all-files\ locally and push fixes.'
body: '⚠️ Linting failed. Please run `pre-commit run --all-files` locally and push fixes.'

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,55 @@
name: Auto-format and Fix Issues

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

Line 1 contains a UTF-8 BOM (invisible character before name:). Removing it avoids potential YAML parsing issues in GitHub Actions and local tooling.

Suggested change
name: Auto-format and Fix Issues
name: Auto-format and Fix Issues

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +34 to +35


Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The fenced code block opened at line 27 isn’t closed until the end of the file, so the entire Roadmap renders as code. Close the ```bash block right after the last command (after pre-commit run --all-files) and keep the Roadmap as normal Markdown text.

Suggested change

Copilot uses AI. Check for mistakes.
Comment thread .pre-commit-config.yaml
@@ -0,0 +1,47 @@
# Pre-commit hooks configuration

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

This file begins with a UTF-8 BOM (invisible character before #). BOMs aren’t needed in UTF-8 and can show up as odd characters in some renderers/tools; please remove it.

Suggested change
# Pre-commit hooks configuration
# Pre-commit hooks configuration

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,17 @@
FRAMEWORK FOR RESPONSIBLE SHARING OF GENOMIC DATA - SAMPLE EXCERPT

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

This sample text file starts with a UTF-8 BOM (invisible character before the first letter). Removing the BOM keeps the sample content clean for any text processing/embedding.

Suggested change
FRAMEWORK FOR RESPONSIBLE SHARING OF GENOMIC DATA - SAMPLE EXCERPT
FRAMEWORK FOR RESPONSIBLE SHARING OF GENOMIC DATA - SAMPLE EXCERPT

Copilot uses AI. Check for mistakes.
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.

dev: Add type hints to source code for better IDE support

2 participants