File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,13 @@ repos:
13
13
- id : check-yaml
14
14
- id : end-of-file-fixer
15
15
- id : trailing-whitespace
16
+ - repo : https://github.com/python/black
17
+ rev : 23.3.0
18
+ hooks :
19
+ - id : black
20
+ - repo : https://github.com/pycqa/pylint
21
+ rev : v2.17.4
22
+ hooks :
23
+ - id : pylint
24
+ name : pylint
25
+ types : [python]
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2023 Alec Delaney, for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """
6
+ Script for checking the packaging of libraries.
7
+
8
+ Author(s): Alec Delaney, for Adafruit Industries
9
+ """
10
+
11
+ import pathlib
12
+ import sys
13
+ import tomllib
14
+ from collections .abc import Iterable
15
+
16
+ with open ("pyproject.toml" , mode = "rb" ) as tomlfile :
17
+ settings = tomllib .load (tomlfile )
18
+
19
+ is_package = settings ["tool" ]["setuptools" ].get ("packages" ) is not None
20
+ libnames : Iterable [str ] = (
21
+ settings ["tool" ]["setuptools" ]["packages" ]
22
+ if is_package
23
+ else settings ["tool" ]["setuptools" ]["py-modules" ]
24
+ )
25
+
26
+ for libname in libnames :
27
+ library_path = pathlib .Path (libname )
28
+ if library_path .is_dir () != is_package :
29
+ REQUIRED_CHANGE = "package" if library_path .is_dir () else "module"
30
+ print (
31
+ f"Library { libname } should be specified as a { REQUIRED_CHANGE } in pyproject.toml!"
32
+ )
33
+ sys .exit (1 )
You can’t perform that action at this time.
0 commit comments