diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4ce0ec7 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 . diff --git a/src/reader/feed.py b/src/reader/feed.py index 16ad7be..3a573e8 100644 --- a/src/reader/feed.py +++ b/src/reader/feed.py @@ -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 @@ -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: @@ -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 += ( @@ -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] diff --git a/src/reader/ruff_issue.py b/src/reader/ruff_issue.py new file mode 100644 index 0000000..1e71f7e --- /dev/null +++ b/src/reader/ruff_issue.py @@ -0,0 +1,4 @@ +import os + +def calculate(x, y): + return x + y \ No newline at end of file diff --git a/src/reader/viewer.py b/src/reader/viewer.py index e2852df..5f55a43 100644 --- a/src/reader/viewer.py +++ b/src/reader/viewer.py @@ -1,7 +1,7 @@ """Functions for displaying the Real Python feed.""" # Standard library imports -from typing import List +from __future__ import annotations def show(article: str) -> None: @@ -9,7 +9,7 @@ def show(article: str) -> None: 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):