Skip to content

Commit 58e4b9d

Browse files
authored
Merge branch 'master' into patch-1
2 parents cb2e590 + 55905f1 commit 58e4b9d

20 files changed

+333
-83
lines changed

.github/workflows/tests.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
- uses: actions/checkout@v3
1717
- uses: actions/setup-python@v3
1818
with:
19-
python-version: '3.8'
19+
python-version: '3.11'
2020

2121
- name: Installation (deps and package)
2222
run: |
23-
pip install . pre-commit mypy==0.910 -r tests/requirements.txt
23+
pip install . pre-commit mypy==1.11.2 -r tests/requirements.txt
2424
2525
- name: run linters
2626
run: |
@@ -33,9 +33,9 @@ jobs:
3333
runs-on: ${{ matrix.os }}
3434
strategy:
3535
matrix:
36-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
36+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13-dev']
3737
os: [ubuntu-latest, macos-latest, windows-latest]
38-
continue-on-error: ${{ matrix.python-version == '3.12-dev' }}
38+
continue-on-error: ${{ matrix.python-version == '3.13-dev' }}
3939

4040
steps:
4141
- uses: actions/checkout@v3
@@ -51,10 +51,10 @@ jobs:
5151
5252
- name: Test with pytest
5353
run: |
54-
pytest --cov --cov-fail-under=100
54+
pytest --cov
5555
5656
- name: Report coverage
57-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'
57+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
5858
uses: codecov/codecov-action@v2
5959

6060
allgood:
@@ -74,7 +74,7 @@ jobs:
7474
- uses: actions/checkout@v3
7575
- uses: actions/setup-python@v3
7676
with:
77-
python-version: '3.8'
77+
python-version: '3.x'
7878
- name: Install build and publish tools
7979
run: |
8080
pip install build twine

.pre-commit-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
3+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
44
hooks:
55
- id: check-yaml
66
- id: check-toml
@@ -23,22 +23,26 @@ repos:
2323
hooks:
2424
- id: absolufy-imports
2525
- repo: https://github.com/PyCQA/isort
26-
rev: dbf82f2dd09ae41d9355bcd7ab69187a19e6bf2f # frozen: 5.12.0
26+
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
2727
hooks:
2828
- id: isort
2929
- repo: https://github.com/psf/black
30-
rev: 193ee766ca496871f93621d6b58d57a6564ff81b # frozen: 23.7.0
30+
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
3131
hooks:
3232
- id: black
33-
- repo: https://github.com/myint/docformatter
34-
rev: dfefe062799848234b4cd60b04aa633c0608025e # frozen: v1.7.5
33+
- repo: https://github.com/hukkin/docformatter
34+
rev: ab802050e6e96aaaf7f917fcbc333bb74e2e57f7 # frozen: v1.4.2
3535
hooks:
3636
- id: docformatter
3737
- repo: https://github.com/PyCQA/flake8
38-
rev: 10f4af6dbcf93456ba7df762278ae61ba3120dc6 # frozen: 6.1.0
38+
rev: e43806be3607110919eff72939fda031776e885a # frozen: 7.1.1
3939
hooks:
4040
- id: flake8
4141
additional_dependencies:
4242
- flake8-bugbear
4343
- flake8-builtins
4444
- flake8-comprehensions
45+
- repo: https://github.com/pre-commit/pre-commit
46+
rev: cc4a52241565440ce200666799eef70626457488 # frozen: v4.0.1
47+
hooks:
48+
- id: validate_manifest

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Note that GitHub's Markdown renderer supports syntax extensions not included in
4141
For full GitHub support do:
4242

4343
```bash
44-
pip install mdformat-gfm mdformat-frontmatter mdformat-footnote
44+
pip install mdformat-gfm mdformat-frontmatter mdformat-footnote mdformat-gfm-alerts
4545
```
4646

4747
Install with [Markedly Structured Text (MyST)](https://myst-parser.readthedocs.io/en/latest/using/syntax.html) support:
@@ -90,7 +90,9 @@ If a file is not properly formatted, the exit code will be non-zero.
9090

9191
```console
9292
foo@bar:~$ mdformat --help
93-
usage: mdformat [-h] [--check] [--version] [--number] [--wrap {keep,no,INTEGER}] [--end-of-line {lf,crlf,keep}] [paths ...]
93+
usage: mdformat [-h] [--check] [--version] [--number] [--wrap {keep,no,INTEGER}]
94+
[--end-of-line {lf,crlf,keep}] [--exclude PATTERN]
95+
[paths ...]
9496

9597
CommonMark compliant Markdown formatter
9698

@@ -106,8 +108,11 @@ options:
106108
paragraph word wrap mode (default: keep)
107109
--end-of-line {lf,crlf,keep}
108110
output file line ending mode (default: lf)
111+
--exclude PATTERN exclude files that match the Unix-style glob pattern (multiple allowed)
109112
```
110113

114+
The `--exclude` option is only available on Python 3.13+.
115+
111116
<!-- end cli-usage -->
112117

113118
## Documentation

docs/contributors/contributing.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ setuptools.setup(
6060
)
6161
```
6262

63-
If using Poetry for packaging, the entry point configuration in `pyproject.toml` would need to be like:
63+
If using a PEP 621 compliant build backend (e.g. Flit) for packaging, the entry point configuration in `pyproject.toml` would need to be like:
6464

6565
```toml
6666
# other config here...
67-
[tool.poetry.plugins."mdformat.codeformatter"]
67+
[project.entry-points."mdformat.codeformatter"]
6868
"python" = "my_package.some_module:format_python"
6969
```
7070

@@ -112,10 +112,17 @@ setuptools.setup(
112112
If using Poetry or Flit for packaging, the entry point configuration in `pyproject.toml` would need to be like:
113113

114114
```toml
115-
# other config here...
115+
# Poetry specific:
116116
[tool.poetry.plugins."mdformat.parser_extension"]
117117
"myextension" = "my_package:ext_module_or_class"
118-
# or
119-
[tool.flit.plugins."mdformat.parser_extension"]
118+
```
119+
120+
```toml
121+
# or PEP 621 compliant (works with Flit):
122+
[project.entry-points."mdformat.parser_extension"]
120123
"myextension" = "my_package:ext_module_or_class"
121124
```
125+
126+
## Making your plugin discoverable
127+
128+
In case you host your plugin on GitHub, make sure to add it under the "mdformat" topic so it shows up on https://github.com/topics/mdformat.

docs/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# List dependencies in a format that readthedocs.org understands.
22

3-
docutils == 0.18.1
4-
sphinx == 5.1.1
5-
myst-parser == 0.18.0
6-
furo == 2022.6.21
3+
docutils == 0.21.2
4+
sphinx == 8.0.2
5+
myst-parser == 4.0.0
6+
furo == 2024.8.6

docs/users/configuration_file.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,34 @@ Command line interface arguments take precedence over the configuration file.
2020
wrap = "keep" # possible values: {"keep", "no", INTEGER}
2121
number = false # possible values: {false, true}
2222
end_of_line = "lf" # possible values: {"lf", "crlf", "keep"}
23+
24+
# Python 3.13+ only:
25+
exclude = [] # possible values: a list of file path pattern strings
26+
```
27+
28+
## Exclude patterns
29+
30+
A list of file exclusion patterns can be defined on Python 3.13+.
31+
Unix-style glob patterns are supported, see
32+
[Python's documentation](https://docs.python.org/3/library/pathlib.html#pattern-language)
33+
for syntax definition.
34+
35+
Glob patterns are matched against relative paths.
36+
If `--exclude` is used on the command line, the paths are relative to current working directory.
37+
Else the paths are relative to the parent directory of the file's `.mdformat.toml`.
38+
39+
Files that match an exclusion pattern are _always_ excluded,
40+
even in the case that they are directly referenced in a command line invocation.
41+
42+
### Example patterns
43+
44+
```toml
45+
# .mdformat.toml
46+
exclude = [
47+
"CHANGELOG.md", # exclude a single root level file
48+
"venv/**", # recursively exclude a root level directory
49+
"**/node_modules/**", # recursively exclude a directory at any level
50+
"**/*.txt", # exclude all .txt files
51+
"**/*.m[!d]", "**/*.[!m]d", # exclude all files that are not suffixed .md
52+
]
2353
```

docs/users/plugins.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ formatted = mdformat.text(unformatted, codeformatters={"python"})
2323
assert formatted == '```python\n"""black converts quotes"""\n```\n'
2424
````
2525

26-
### Existing plugins
26+
### Existing plugins (see https://github.com/topics/mdformat for more!)
2727

2828
<table>
2929
<tr>
@@ -51,6 +51,11 @@ assert formatted == '```python\n"""black converts quotes"""\n```\n'
5151
<td><code>go</code></td>
5252
<td>Requires <a href="https://golang.org/doc/install">Go</a> installation</td>
5353
</tr>
54+
<tr>
55+
<td><a href="https://github.com/Freed-Wu/mdformat-ruff">mdformat-ruff</a></td>
56+
<td><code>python</code></td>
57+
<td></td>
58+
</tr>
5459
<tr>
5560
<td><a href="https://github.com/hukkin/mdformat-rustfmt">mdformat-rustfmt</a></td>
5661
<td><code>rust</code></td>
@@ -85,7 +90,7 @@ unformatted = "content...\n"
8590
formatted = mdformat.text(unformatted, extensions={"tables"})
8691
```
8792

88-
### Existing plugins
93+
### Existing plugins (see https://github.com/topics/mdformat for more!)
8994

9095
<table>
9196
<tr>
@@ -118,6 +123,11 @@ formatted = mdformat.text(unformatted, extensions={"tables"})
118123
<td><code>gfm</code></td>
119124
<td>Changes target specification to GitHub Flavored Markdown (GFM)</td>
120125
</tr>
126+
<tr>
127+
<td><a href="https://github.com/KyleKing/mdformat-gfm-alerts">mdformat-gfm-alerts</a></td>
128+
<td><code>gfm_alerts</code></td>
129+
<td>Extends GitHub Flavored Markdown (GFM) with "Alerts"</td>
130+
</tr>
121131
<tr>
122132
<td><a href="https://github.com/KyleKing/mdformat-mkdocs">mdformat-mkdocs</a></td>
123133
<td><code>mkdocs</code></td>

pyproject.toml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
{ name = "Taneli Hukkinen", email = "[email protected]" },
1212
]
1313
license = { file = "LICENSE" }
14-
requires-python = ">=3.8"
14+
requires-python = ">=3.9"
1515
dependencies = [
1616
'markdown-it-py >=1.0.0,<4.0.0',
1717
'tomli >=1.1.0; python_version < "3.11"',
@@ -63,15 +63,15 @@ xfail_strict = true
6363
legacy_tox_ini = '''
6464
[tox]
6565
# Only run pytest envs when no args given to tox
66-
envlist = py{38,39,310,311}
66+
envlist = py{39,310,311,312,313}
6767
isolated_build = True
6868
69-
[testenv:py{38,39,310,311}]
69+
[testenv:py{39,310,311,312,313}]
7070
description = run tests
7171
deps =
7272
-r tests/requirements.txt
7373
commands =
74-
pytest {posargs}
74+
pytest {posargs:--cov}
7575
7676
[testenv:profile]
7777
description = run profiler (use e.g. `firefox .tox/prof/combined.svg` to open)
@@ -90,10 +90,10 @@ commands = pre-commit run {posargs:--all}
9090
9191
[testenv:mypy]
9292
description = run mypy
93-
basepython = python3.8
93+
basepython = python3.11
9494
deps =
9595
-r tests/requirements.txt
96-
mypy==0.910
96+
mypy==1.11.2
9797
commands =
9898
mypy {posargs:src/ tests/}
9999
@@ -135,20 +135,7 @@ commands =
135135

136136
[tool.coverage.run]
137137
source = ["mdformat"]
138-
omit = ["*/__main__.py"]
139-
140-
[tool.coverage.report]
141-
# Regexes for lines to exclude from consideration
142-
exclude_lines = [
143-
# Re-enable the standard pragma (with extra strictness)
144-
'# pragma: no cover\b',
145-
# Ellipsis lines after @typing.overload
146-
'^ +\.\.\.$',
147-
# Code for static type checkers
148-
"if TYPE_CHECKING:",
149-
# Scripts
150-
'if __name__ == .__main__.:',
151-
]
138+
plugins = ["covdefaults"]
152139

153140

154141
[tool.mypy]
@@ -168,8 +155,3 @@ no_implicit_optional = true
168155
[[tool.mypy.overrides]]
169156
module = "tests.*"
170157
disallow_untyped_defs = false
171-
172-
[[tool.mypy.overrides]]
173-
# This matches `fuzzer/fuzz.py`.
174-
module = "fuzz"
175-
ignore_errors = true

0 commit comments

Comments
 (0)