Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sanjay - GitHub Actions Learning

on:
pull_request:
branches:
- github-actions-tutorial
- main

workflow_dispatch:

jobs:
Linting-check:
runs-on: ubuntu-latest

steps:
- name: Say Hello
run: echo "Hello Sanjay! My first GitHub Action is running."

- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-verson: "3.13"

- name: Install Ruff
run: python -m pip install Ruff

- name: Run Ruff
run: ruff check .
11 changes: 7 additions & 4 deletions src/reader/feed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Interact with the Real Python feed."""
# Standard library imports
from typing import Dict, List
from __future__ import annotations

# Third party imports
import feedparser
Expand All @@ -9,7 +9,7 @@
# Reader imports
from reader import URL

_CACHED_FEEDS: Dict[str, feedparser.FeedParserDict] = {}
_CACHED_FEEDS: dict[str, feedparser.FeedParserDict] = {}


def _feed(url: str = URL) -> feedparser.FeedParserDict:
Expand All @@ -21,8 +21,11 @@ def _feed(url: str = URL) -> feedparser.FeedParserDict:

def get_site(url: str = URL) -> str:
"""Get name and link to website of the feed."""
# info = _feed(url)
# if exception := info.get("bozo_exception"):
info = _feed(url)
if exception := info.get("bozo_exception"):
exception = info.get("bozo_exception")
if exception:
message = f"Could not read feed at {url}"
if "CERTIFICATE_VERIFY_FAILED" in str(exception):
message += (
Expand Down Expand Up @@ -58,7 +61,7 @@ def get_article(article_id: str, links: bool = False, url: str = URL) -> str:
return f"# {article.title}\n\n{text}"


def get_titles(url: str = URL) -> List[str]:
def get_titles(url: str = URL) -> list[str]:
"""List titles in feed."""
articles = _feed(url).entries
return [a.title for a in articles]
4 changes: 4 additions & 0 deletions src/reader/ruff_issue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

def calculate(x, y):
return x + y
4 changes: 2 additions & 2 deletions src/reader/viewer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Functions for displaying the Real Python feed."""

# Standard library imports
from typing import List
from __future__ import annotations


def show(article: str) -> None:
"""Show one article."""
print(article)


def show_list(site: str, titles: List[str]) -> None:
def show_list(site: str, titles: list[str]) -> None:
"""Show list of articles."""
print(f"The latest tutorials from {site}")
for article_id, title in enumerate(titles):
Expand Down