Skip to content

Commit 2e9dfab

Browse files
committed
Add markdownlint to linting job
1 parent 68dc0bc commit 2e9dfab

6 files changed

Lines changed: 80 additions & 40 deletions

File tree

.config/.markdownlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
line-length:
2+
line_length: 200
3+
tables: false
4+
no-hard-tabs: false
5+
commands-show-output: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
line-length:
2+
line_length: 300
3+
no-inline-html:
4+
allowed_elements: ['p', 'img']
5+
ul-style:
6+
style: sublist
7+
no-duplicate-heading:
8+
siblings_only: true
9+
blanks-around-headings:
10+
lines_below: 0
11+
blanks-around-lists: false

.github/workflows/test.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ jobs:
101101
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102102
run: |
103103
uvx zizmor --format plain .
104+
105+
- name: Lint CHANGELOG
106+
uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v19
107+
with:
108+
config: '.config/changelog.markdownlint.yaml'
109+
globs: 'CHANGELOG.md'
110+
111+
- name: Lint Other Markdown
112+
uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v19
113+
with:
114+
config: '.config/.markdownlint.yaml'
115+
globs: |
116+
**/README.md

CHANGELOG.md

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ the minified code may only run with Python 3.12.
3636

3737
### Added
3838
- Python 3.13 support, including:
39-
- PEP 696 Type parameter defaults
39+
+ PEP 696 Type parameter defaults
4040

4141
## [2.10.0] - 2024-09-15
4242

4343
### Added
4444
- Python 3.12 support, including:
45-
- PEP 695 Type parameter syntax
46-
- PEP 701 Improved f-strings
45+
+ PEP 695 Type parameter syntax
46+
+ PEP 701 Improved f-strings
4747

4848
- A new transform to remove the brackets when instantiating and raising built-in exceptions, which is enabled by default.
4949
e.g.
@@ -58,7 +58,7 @@ the minified code may only run with Python 3.12.
5858
```python
5959
def a():raise ValueError
6060
```
61-
61+
6262
The raise statement automatically instantiates classes derived from Exception, so the brackets are not required.
6363

6464
- A new constant folding transform, which is enabled by default.
@@ -69,16 +69,17 @@ the minified code may only run with Python 3.12.
6969
```
7070

7171
Will be minified to:
72+
7273
```python
7374
SECONDS_IN_A_DAY=86400
7475
```
7576

7677
### Changed
7778
- Annotation removal is now more configurable, with separate options for:
78-
- Removal of variable annotations (`--no-remove-variable-annotations`)
79-
- Removal of function return annotations (`--no-remove-return-annotations`)
80-
- Removal of function argument annotations (`--no-remove-argument-annotations`)
81-
- Removal of class attribute annotations (`--remove-class-attribute-annotations`)
79+
+ Removal of variable annotations (`--no-remove-variable-annotations`)
80+
+ Removal of function return annotations (`--no-remove-return-annotations`)
81+
+ Removal of function argument annotations (`--no-remove-argument-annotations`)
82+
+ Removal of class attribute annotations (`--remove-class-attribute-annotations`)
8283

8384
The default behavior has changed, with class attribute annotations no longer removed by default.
8485
These are increasingly being used at runtime, and removing them can cause issues.
@@ -117,10 +118,10 @@ the minified code may only run with Python 3.12.
117118
The debug specifier should now be preserved where it is used in the input source.
118119

119120
- Many small improvements to minification to be more precise about where whitespace or parentheses required
120-
- Thanks [luk3yx](https://github.com/luk3yx) for improving whitespace in relative import statements.
121-
- A generator as the sole argument to a function call is no longer wrapped in parentheses
122-
- float literals can use a more compact scientific notation
123-
- Many more subtle improvements
121+
+ Thanks [luk3yx](https://github.com/luk3yx) for improving whitespace in relative import statements.
122+
+ A generator as the sole argument to a function call is no longer wrapped in parentheses
123+
+ float literals can use a more compact scientific notation
124+
+ Many more subtle improvements
124125

125126
## [2.8.1] - 2023-03-15
126127

@@ -132,8 +133,8 @@ the minified code may only run with Python 3.12.
132133

133134
### Added
134135
- New transforms that together work similarly to Python's [-O option](https://docs.python.org/3/using/cmdline.html#cmdoption-O)
135-
- Remove asserts, which removes assert statements and is disabled by default
136-
- Remove debug, which removes any `if` block that tests `__debug__ is True` and is disabled by default
136+
+ Remove asserts, which removes assert statements and is disabled by default
137+
+ Remove debug, which removes any `if` block that tests `__debug__ is True` and is disabled by default
137138

138139
### Changed
139140
- When minifiying a directory, files ending with '.pyw' will now be minified.
@@ -144,7 +145,7 @@ the minified code may only run with Python 3.12.
144145
- Python 3.11 support, including exception groups syntax
145146

146147
### Changed
147-
- Improved detection of dataclasses when using the remove annotations transform,
148+
- Improved detection of dataclasses when using the remove annotations transform,
148149
which suppresses removal of annotations for those classes
149150

150151
### Fixed
@@ -156,10 +157,10 @@ the minified code may only run with Python 3.12.
156157
### Added
157158
- A new option to preserve the shebang line from the source file, which is enabled by default
158159
- More flexible file processing options for the `pyminify` command:
159-
- A new `--output` argument for writing the minified output to a file without having to use shell redirection
160-
- A new `--in-place` option which overwrites the specified path with the minified output
161-
- `path` arguments may be directories, which minifies all *.py files below that directory
162-
- Multiple `path` arguments may be specified, which will all be minified
160+
+ A new `--output` argument for writing the minified output to a file without having to use shell redirection
161+
+ A new `--in-place` option which overwrites the specified path with the minified output
162+
+ `path` arguments may be directories, which minifies all *.py files below that directory
163+
+ Multiple `path` arguments may be specified, which will all be minified
163164
- Type information is included in the package to enable type checking of the public functions
164165

165166
### Fixed
@@ -192,7 +193,7 @@ the minified code may only run with Python 3.12.
192193

193194
### Added
194195
- Support for Python 3.9, including:
195-
- PEP 614 - Relaxing Grammar Restrictions On Decorators
196+
+ PEP 614 - Relaxing Grammar Restrictions On Decorators
196197

197198
## [2.3.2] - 2020-10-11
198199

@@ -208,7 +209,7 @@ the minified code may only run with Python 3.12.
208209

209210
### Added
210211
- Optional source transform:
211-
- convert positional arguments to normal arguments, enabled by default
212+
+ convert positional arguments to normal arguments, enabled by default
212213

213214
### Fixed
214215
- Unnecessary spaces after ',' in tuple values
@@ -222,11 +223,12 @@ the minified code may only run with Python 3.12.
222223
- Fixed PendingDeprecationWarnings
223224

224225
## [2.2.0] - 2019-10-27
226+
225227
### Added
226228
- Support for Python 3.8 language features:
227-
- Assignment expressions
228-
- Positional parameters
229-
- f-string = specifier
229+
+ Assignment expressions
230+
+ Positional parameters
231+
+ f-string = specifier
230232

231233
### Changed
232234
- Removed unnecessary parenthesis around yield statements
@@ -235,27 +237,31 @@ the minified code may only run with Python 3.12.
235237
- Reading from stdin
236238

237239
## [2.1.2] - 2019-06-27
240+
238241
### Changed
239242
- Improved renaming performance
240243

241244
## [2.1.1] - 2019-04-07
245+
242246
### Changed
243247
- Removed redundant parentheses from comprehension iteration values
244248

245249
## [2.1.0] - 2019-01-24
250+
246251
### Added
247252
- Optional source transforms:
248-
- remove object base, enabled by default
253+
+ remove object base, enabled by default
249254

250255
### Changed
251256
- Return statements no longer wrap tuples in extraneous parentheses
252257
- Duplicated literals are only raised to the lowest common function namespace
253258

254259
## [2.0.0] - 2019-01-13
260+
255261
### Added
256262
- Optional source transformations:
257-
- Rename locals, enabled by default
258-
- Rename globals, disabled by default
263+
+ Rename locals, enabled by default
264+
+ Rename globals, disabled by default
259265

260266
### Changed
261267
- Minified code will no longer have leading or trailing whitespace
@@ -268,15 +274,17 @@ the minified code may only run with Python 3.12.
268274
- Python 3.7 dataclass field annotations are no longer removed when the remove annotation transformation is enabled
269275

270276
## [1.1.0] - 2018-06-05
277+
271278
### Added
272279
- Optional source transformations:
273-
- Combine import statements
274-
- Remove annotations
275-
- Remove pass statements
276-
- Remove unused literals, including docstrings
277-
- Move duplicated literals into module level variables
280+
+ Combine import statements
281+
+ Remove annotations
282+
+ Remove pass statements
283+
+ Remove unused literals, including docstrings
284+
+ Move duplicated literals into module level variables
278285

279286
## [1.0.0] - 2018-05-25
287+
280288
### Added
281289
- python-minifier package
282290
- pyminify command

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def handler(event,context):
9393

9494
## Why?
9595

96-
AWS Cloudformation templates may have AWS lambda function source code embedded in them, but only if the function is less
96+
AWS Cloudformation templates may have AWS lambda function source code embedded in them, but only if the function is less
9797
than 4KiB. I wrote this package so I could write python normally and still embed the module in a template.
9898

9999
## Installation

src/python_minifier/rename/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We can save bytes by shortening the names used in a python program.
44

5-
One simple way to do this is to replace each unique name in a module with a shorter one.
5+
One simple way to do this is to replace each unique name in a module with a shorter one.
66
This will probably exhaust the available single character names, so is not as efficient as it could be.
77
Also, not all names can be safely changed this way.
88

@@ -22,6 +22,7 @@ Namespaces in python are introduced by Modules, Functions, Comprehensions, Gener
2222
The AST node that introduces a new namespace is called a 'namespace node'.
2323

2424
These attributes are added to namespace nodes:
25+
2526
- Bindings - A list of Bindings local to this namespace, populated by the Bind names step
2627
- Globals - A list of global names in this namespace
2728
- Nonlocals - A list of nonlocal names in this namespace
@@ -50,6 +51,7 @@ The node is added to the NameBinding as a reference.
5051
If the name is nonlocal in its namespace it does not create a binding.
5152

5253
Nodes that create a binding:
54+
5355
- FunctionDef nodes bind their name
5456
- ClassDef nodes bind their name
5557
- arg nodes bind their arg
@@ -68,10 +70,10 @@ If a name is nonlocal in a searched namespace, skip to the next parent namespace
6870
When traversing parent namespaces, Class namespaces are skipped.
6971

7072
If a NameBinding is found, add the node as a reference.
71-
If no NameBinding is found, check if the name would resolve to a builtin.
73+
If no NameBinding is found, check if the name would resolve to a builtin.
7274
If so, create a BuiltinBinding in the module namespace and add this node as a reference.
7375

74-
Otherwise we failed to find a binding for this name - Create a NameBinding in the module namespace and add this node
76+
Otherwise we failed to find a binding for this name - Create a NameBinding in the module namespace and add this node
7577
as a reference.
7678

7779
## Hoist Literals
@@ -84,7 +86,8 @@ to introduce new names.
8486
Collect all bindings in the module and sort by estimated byte savings
8587

8688
For each binding:
87-
- Determine it's 'reservation scope', which is the set of namespaces that name is referenced in (and all namespaces between them)
88-
- Get the next available name that is unassigned and unreserved in all namespaces in the reservation scope.
89-
- Check if we should proceed with the rename - is it space efficient to do this rename, or has the original name been assigned somewhere else?
90-
- Rename the binding, rename all referenced nodes to the new name, and record this name as assigned in every namespace of the reservation scope.
89+
90+
- Determine it's 'reservation scope', which is the set of namespaces that name is referenced in (and all namespaces between them)
91+
- Get the next available name that is unassigned and unreserved in all namespaces in the reservation scope.
92+
- Check if we should proceed with the rename - is it space efficient to do this rename, or has the original name been assigned somewhere else?
93+
- Rename the binding, rename all referenced nodes to the new name, and record this name as assigned in every namespace of the reservation scope.

0 commit comments

Comments
 (0)