Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to PDM & Ruff from Poetry & Flake8/isort #22

Merged
merged 5 commits into from
Jan 30, 2024
Merged
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
41 changes: 15 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,23 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3

- name: Install Poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }} & PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
cache: true
cache-dependency-path: ./pyproject.toml

- name: Install dependencies
run: |
poetry env use "${{ matrix.python-version }}"
poetry install --no-interaction
run: pdm install

- name: Run tests
run: poetry run invoke tests

run: pdm run invoke tests

lint:
name: Lint
Expand All @@ -46,23 +41,18 @@ jobs:
with:
retry: true

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
- name: Set up Python & PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: "3.9"
cache: "poetry"
python-version: "3.10"
cache: true
cache-dependency-path: ./pyproject.toml

- name: Install dependencies
run: |
poetry env use "3.9"
poetry install --no-interaction
run: pdm install

- name: Run linters
run: poetry run invoke lint --diff

run: pdm run invoke lint --diff

deploy:
name: Deploy
Expand All @@ -83,12 +73,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.10"

- name: Check release
id: check_release
run: |
python -m pip install --upgrade pip
python -m pip install autopub[github]
autopub check

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ __pycache__/

# Unit test / coverage reports
.pytest_cache/

# PDM
.pdm-python
pdm.lock
27 changes: 6 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
# See https://pre-commit.com/hooks.html for info on hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -20,24 +20,9 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: [--max-line-length=88]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- id: ruff
- id: ruff-format
args: ["--check"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This plugin can be installed via:

python -m pip install pelican-webring

As long as you have not explicitly added a `PLUGINS` setting to your Pelican settings file, then the newly-installed plugin should be automatically detected and enabled. Otherwise, you must add `webring` to your existing `PLUGINS` list. For more information, please see the [How to Use Plugins](https://docs.getpelican.com/en/latest/plugins.html#how-to-use-plugins) documentation.

Settings
--------

Expand Down
7 changes: 4 additions & 3 deletions pelican/plugins/webring/test_webring.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for webring plugin
"""Tests for webring plugin.

Test Atom and RSS feeds have been generated using Pelican itself using the
contents of its `samples/content` folder.
Expand All @@ -13,7 +13,6 @@
from pelican.generators import Generator
from pelican.settings import DEFAULT_CONFIG
from pelican.tests.support import get_context, get_settings, module_exists

import webring


Expand Down Expand Up @@ -69,7 +68,9 @@ def test_articles_per_feed(self):
self.assertEqual(list(map(itemgetter(1), feed_counts.items())), [3, 3])

def test_common_attributes(self):
"""These are attributes present in ALL articles in both RSS and Atom test feeds.
"""Test common attributes.

These are attributes present in ALL articles in both RSS and Atom test feeds.
Optional attributes are not checked.
"""
webring.fetch_feeds(self.generators)
Expand Down
14 changes: 5 additions & 9 deletions pelican/plugins/webring/webring.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Webring plugin for Pelican
==========================
"""Webring plugin for Pelican.

A plugin to create a webring or feed aggregation in your web site from a list
of web feeds.
Expand Down Expand Up @@ -35,7 +33,7 @@ def __init__(
self._source = source

def __getattr__(self, key):
"""Lazy build special attributes"""
"""Lazy build special attributes."""
try:
if key.startswith("source_"):
entry_id = key.partition("_")[2]
Expand Down Expand Up @@ -119,8 +117,7 @@ def get_feed_html(feed_url):
req.add_header(
"User-Agent",
(
"Webring Pelican plugin/{} "
+ "+https://github.com/pelican/pelican-plugins"
"Webring Pelican plugin/{} +https://github.com/pelican/pelican-plugins"
).format(WEBRING_VERSION),
)
return urlopen(req).read().decode("utf-8")
Expand All @@ -142,7 +139,7 @@ def get_feed_articles(feed_html, feed_url):

if parsed_feed.bozo:
warning(
"webring plugin: possible malformed or invalid feed (%s). " "Error=%s",
"webring plugin: possible malformed or invalid feed (%s). Error=%s",
feed_url,
parsed_feed.bozo_exception,
)
Expand All @@ -168,8 +165,7 @@ def get_entry_summary(entry):
# https://stackoverflow.com/a/12982689/11441
def cleanhtml(raw_html):
cleanr = re.compile("<.*?>")
cleantext = re.sub(cleanr, "", raw_html)
return cleantext
return re.sub(cleanr, "", raw_html)

try:
# this will get the first of 'summary' and 'subtitle'
Expand Down
Loading