Skip to content

Commit 52036a4

Browse files
authored
Python Dependency Update / Docs Dependencies / Remove Black (#55)
* dropping support for py 3.8 in anticipation of oct 2024 * separate dependencies and add docs depnds * remove black and use ruff only * track workflow too * fix 3.8 linting issues
1 parent f9cbfd5 commit 52036a4

File tree

10 files changed

+58
-69
lines changed

10 files changed

+58
-69
lines changed

.github/workflows/python-types-lint-format.yaml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ on:
66
branches: [ main ]
77
paths:
88
- '**.py'
9+
- ".github/workflows/python-types-lint-format.yaml"
910

1011
pull_request:
1112
branches: [ main ]
1213
paths:
1314
- '**.py'
15+
- ".github/workflows/python-types-lint-format.yaml"
1416

1517
permissions:
1618
contents: read
@@ -23,7 +25,7 @@ jobs:
2325
strategy:
2426
matrix:
2527
os: [ubuntu-latest]
26-
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
28+
python_version: ["3.9", "3.10", "3.11", "3.12"]
2729
steps:
2830
- uses: actions/checkout@v4
2931
- uses: actions/setup-python@v5
@@ -36,16 +38,16 @@ jobs:
3638
python3 -m pip install -e '.[dev]'
3739
3840
- name: Run type check
39-
run: python -m mypy .
41+
run: python3 -m mypy .
4042

41-
python-lint-check:
43+
python-lint-format-check:
4244
if: ${{ always() }} # Always run even if a matrix candidate fails
43-
name: Python ${{ matrix.python_version }} - Check Linting - ${{ matrix.os }}
45+
name: Python ${{ matrix.python_version }} - Check Linting and Formatting - ${{ matrix.os }}
4446
runs-on: ${{ matrix.os }}
4547
strategy:
4648
matrix:
4749
os: [ubuntu-latest]
48-
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
50+
python_version: ["3.9", "3.10", "3.11", "3.12"]
4951
steps:
5052
- uses: actions/checkout@v4
5153
- uses: actions/setup-python@v5
@@ -55,29 +57,10 @@ jobs:
5557
- name: Install dependencies
5658
run: |
5759
python3 -m pip install --upgrade pip
58-
python3 -m pip install -e '.[dev]'
60+
python3 -m pip install -e '.[lint]'
5961
6062
- name: Run lint check
61-
run: python -m ruff check .
62-
63-
python-format-check:
64-
if: ${{ always() }} # Always run even if a matrix candidate fails
65-
name: Python ${{ matrix.python_version }} - Check formatting - ${{ matrix.os }}
66-
runs-on: ${{ matrix.os }}
67-
strategy:
68-
matrix:
69-
os: [ubuntu-latest]
70-
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
71-
steps:
72-
- uses: actions/checkout@v4
73-
- uses: actions/setup-python@v5
74-
with:
75-
python-version: ${{ matrix.python_version }}
76-
architecture: x64
77-
- name: Install dependencies
78-
run: |
79-
python3 -m pip install --upgrade pip
80-
python3 -m pip install -e '.[dev]'
63+
run: python3 -m ruff check .
8164

8265
- name: Run format check
83-
run: python -m black .
66+
run: python3 -m ruff format . --check

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
env:
10-
DEFAULT_PYTHON: 3.8
10+
DEFAULT_PYTHON: 3.9
1111

1212
jobs:
1313
release-pypi:
@@ -22,9 +22,9 @@ jobs:
2222
with:
2323
python-version: ${{ env.DEFAULT_PYTHON }}
2424
- name: Install requirements
25-
run: python -m pip install build twine
25+
run: python3 -m pip install build twine
2626
- name: Build distributions
27-
run: python -m build
27+
run: python3 -m build
2828
- name: Upload to PyPI
2929
env:
3030
TWINE_REPOSITORY: pypi

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ repos:
2020
hooks:
2121
- id: ruff
2222
args: ["--fix"]
23-
- repo: https://github.com/psf/black-pre-commit-mirror
24-
rev: 24.3.0
25-
hooks:
26-
- id: black
23+
# Run the formatter.
24+
- id: ruff-format

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
"purpose": ["debug-test"],
1313
"console": "integratedTerminal",
1414
"justMyCode": false
15+
},
16+
{
17+
"name": "Serve MkDocs",
18+
"type": "debugpy",
19+
"request": "launch",
20+
"python": "${workspaceFolder}/.venv/bin/python",
21+
"cwd": "${workspaceFolder}",
22+
"module": "mkdocs",
23+
"args": ["serve", "-f", "docs/mkdocs.yml"],
24+
"console": "integratedTerminal",
1525
}
1626
]
1727
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ This repository is open for everyone to contribute and is maintained by [John Az
88

99
## Develop Locally
1010

11-
To run the the package locally (Lean more: [here](https://python-packaging-tutorial.readthedocs.io/2018/setup_py.html#under-development)):
11+
To run the the package locally (Lean more: [here](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#working-in-development-mode)):
1212

1313
```shell
14-
python setup.py develop
14+
pip install -e .
1515
```
1616

1717
Any changes you do will take effect immediately.

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Markdown link validation reporting tool. It provides a couple of functions to va
66

77
You will need the following prerequisites in order to use this library:
88

9-
- Python >= 3.8
9+
- Python >= 3.9
1010
- [requests](https://pypi.org/project/requests/)
1111

1212
## Installation

pyproject.toml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ maintainers = [{ name = "John Aziz", email = "[email protected]" }]
1111
license = {file = "LICENSE"}
1212
readme = "README.md"
1313

14-
requires-python = ">=3.8"
14+
requires-python = ">=3.9"
1515
dependencies = [
1616
"requests",
1717
"types-requests",
@@ -21,7 +21,6 @@ classifiers = [
2121
"License :: OSI Approved :: MIT License",
2222
"Operating System :: OS Independent",
2323
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
2726
"Programming Language :: Python :: 3.11",
@@ -40,26 +39,29 @@ Releases = "https://github.com/john0isaac/markdown-checker/releases"
4039

4140
[project.optional-dependencies]
4241
dev = [
43-
"pytest",
44-
"pytest-cov",
4542
"pre-commit",
46-
"ruff",
47-
"black",
48-
"mypy",
43+
"mypy"
44+
]
45+
lint = [
46+
"ruff"
47+
]
48+
test = [
49+
"pytest",
50+
"pytest-cov"
51+
]
52+
docs = [
53+
"mkdocs",
54+
"mkdocs-material",
55+
"mkdocstrings[python]",
56+
"pymdown-extensions"
4957
]
5058

5159
[tool.ruff]
60+
lint.select = ["E", "F", "I", "UP"]
5261
line-length = 120
53-
target-version = "py38"
62+
target-version = "py39"
5463
src = ["src"]
5564
output-format = "full"
5665

57-
[tool.ruff.lint]
58-
select = ["E", "F", "I", "UP"]
59-
60-
[tool.black]
61-
line-length = 120
62-
target-version = ["py38"]
63-
6466
[project.scripts]
6567
markdown-checker = "markdown_checker.validate_markdown:main"

src/markdown_checker/check_markdown.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
following some Guidelines
44
"""
55

6-
from typing import List
7-
86
from markdown_checker.links.link_operations import (
97
check_paths_exists,
108
check_url_alive,
@@ -62,7 +60,7 @@ def check_broken_links(file_path: str, link_type: str, check_type: str) -> str:
6260
return ""
6361

6462

65-
def format_links(links: List[str]) -> str:
63+
def format_links(links: list[str]) -> str:
6664
"""
6765
Formats a List of links into a string with numbered bullets.
6866

src/markdown_checker/links/link_operations.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import os
22
import re
3-
from typing import List
43

54

6-
def get_links_from_file(file_path: str) -> List[str]:
5+
def get_links_from_file(file_path: str) -> list[str]:
76
"""function to get an array of markdown links from a file
87
flags markdown links captures the part inside () that comes right after []
98
"""
@@ -18,7 +17,7 @@ def get_links_from_file(file_path: str) -> List[str]:
1817
return all_links
1918

2019

21-
def get_urls_from_links(all_links: List[str]) -> List[str]:
20+
def get_urls_from_links(all_links: list[str]) -> list[str]:
2221
"""function to get an array of urls from a List"""
2322
urls = []
2423
url_pattern = re.compile(
@@ -39,7 +38,7 @@ def get_urls_from_links(all_links: List[str]) -> List[str]:
3938
return urls
4039

4140

42-
def get_paths_from_links(all_links: List[str]) -> List[str]:
41+
def get_paths_from_links(all_links: list[str]) -> list[str]:
4342
"""function to get relative paths from a List
4443
flags paths that start with ./ or ../
4544
"""
@@ -54,7 +53,7 @@ def get_paths_from_links(all_links: List[str]) -> List[str]:
5453
return paths
5554

5655

57-
def check_paths_exists(file_path: str, paths: List[str]) -> List[str]:
56+
def check_paths_exists(file_path: str, paths: list[str]) -> list[str]:
5857
"""function checks if a path exist if not return non existent paths
5958
flags any relative path that can't be accessed
6059
"""
@@ -66,7 +65,7 @@ def check_paths_exists(file_path: str, paths: List[str]) -> List[str]:
6665
return broken_path
6766

6867

69-
def check_url_locale(urls: List[str]) -> List[str]:
68+
def check_url_locale(urls: list[str]) -> list[str]:
7069
"""function checks if a url has country locale
7170
flags urls that have ==> /en-us/
7271
"""
@@ -81,7 +80,7 @@ def check_url_locale(urls: List[str]) -> List[str]:
8180
return country_locale
8281

8382

84-
def check_url_tracking(urls: List[str]) -> List[str]:
83+
def check_url_tracking(urls: list[str]) -> list[str]:
8584
"""function checks if a url has tracking id
8685
flags urls missing ==> (? or &) plus WT.mc_id= or wt.mc_id=
8786
"""
@@ -94,7 +93,7 @@ def check_url_tracking(urls: List[str]) -> List[str]:
9493
return tracking_id
9594

9695

97-
def check_url_alive(urls: List[str]) -> List[str]:
96+
def check_url_alive(urls: list[str]) -> list[str]:
9897
import requests # type: ignore
9998

10099
broken_urls = []
@@ -112,7 +111,7 @@ def check_url_alive(urls: List[str]) -> List[str]:
112111

113112

114113
# DEPRECATED
115-
def get_urls_from_file(file_path: str) -> List[str]:
114+
def get_urls_from_file(file_path: str) -> list[str]:
116115
"""function to get an array of urls from a file"""
117116
urls = []
118117
with open(file_path, encoding="utf-8") as file:
@@ -126,7 +125,7 @@ def get_urls_from_file(file_path: str) -> List[str]:
126125
return urls
127126

128127

129-
def get_paths_from_file(file_path: str) -> List[str]:
128+
def get_paths_from_file(file_path: str) -> list[str]:
130129
"""function to get relative paths from a file"""
131130
paths = []
132131
with open(file_path, encoding="utf-8") as file:

src/markdown_checker/paths/files_paths_reader.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
"""
1010

1111
import os
12-
from typing import List, Tuple
1312

1413

15-
def get_files_paths_list(root_path: str, extensions: List[str] = []) -> Tuple[List[str], List[str]]:
14+
def get_files_paths_list(root_path: str, extensions: list[str] = []) -> tuple[list[str], list[str]]:
1615
"""
1716
function returns a list of files in a directory and its subdirectories,
1817
filtered by file extensions.
@@ -28,8 +27,8 @@ def get_files_paths_list(root_path: str, extensions: List[str] = []) -> Tuple[Li
2827
if len(extensions) == 0:
2928
extensions = [".md", ".ipynb"]
3029

31-
sub_folders: List[str] = []
32-
files_paths: List[str] = []
30+
sub_folders: list[str] = []
31+
files_paths: list[str] = []
3332

3433
for f in os.scandir(root_path):
3534
if f.is_dir():

0 commit comments

Comments
 (0)