Skip to content

Commit cc215e5

Browse files
authored
Support flake8 v5+ (#12)
* Rename "I20xx" to "IMR2xx" in codes. * Removed support for Python 3.7 and added 3.10 and 3.11. * Fix requirement versions. * Fix Github actions.
1 parent 795efbe commit cc215e5

29 files changed

+239
-225
lines changed

.github/workflows/python-black.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
max-parallel: 4
99
matrix:
10-
python-version: [3.8]
10+
python-version: [3.11]
1111

1212
steps:
1313
- uses: actions/checkout@v1

.github/workflows/python-flake8.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
max-parallel: 4
99
matrix:
10-
python-version: [3.8]
10+
python-version: [3.11]
1111

1212
steps:
1313
- uses: actions/checkout@v1

.github/workflows/python-pylint.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: pylint
2-
on: [push, pull_request]
2+
3+
on: [push]
34

45
jobs:
56
build:
67
runs-on: ubuntu-latest
78
strategy:
89
max-parallel: 4
910
matrix:
10-
python-version: [3.8]
11+
python-version: [3.11]
1112

1213
steps:
1314
- uses: actions/checkout@v1
1415
- name: Set up Python ${{ matrix.python-version }}
1516
uses: actions/setup-python@v2
1617
with:
1718
python-version: ${{ matrix.python-version }}
18-
- name: GitHub Action for pylint
19-
uses: cclauss/[email protected]
20-
with:
21-
args: "pip install pylint -r requirements/py38.txt ; pylint flake8_import_restrictions/*.py -E"
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install pylint -r requirements/py311.txt
23+
- name: pylint
24+
run: |
25+
python -m pylint flake8_import_restrictions/*.py -E

.github/workflows/python-tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
max-parallel: 4
99
matrix:
10-
python-version: [3.7, 3.8]
10+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1111

1212
steps:
1313
- uses: actions/checkout@v1

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ and the `from` syntax (`from X.Y import Z [as foo]`). It talks about
1212
segments (`as Z`).
1313

1414
## Options
15-
For every error `I20xx` listed below, there are options `--i20xx_include` and `--i20xx_exclude`
15+
For every error `IMR2xx` listed below, there are options `--imr2xx_include` and `--imr2xx_exclude`
1616
which are passed a comma separated list of UNIX wildcard patterns each. The error
1717
will then only be reported on imports of modules that match a include pattern but no exclude
1818
pattern.
1919

20-
By default, I2000, I2001, I2002, I2021, I2023, I2041, and I2043 include all (`*`) modules. Only I2041 excludes the
20+
By default, IMR200, IMR201, IMR202, IMR221, IMR223, IMR241, and IMR243 include all (`*`) modules. Only IMR241 excludes the
2121
`typing` module from checks, the other errors have no excludes by default.
2222

2323
## General Import Errors
2424

25-
### I2000
25+
### IMR200
2626
Imports should only happen on module level, not locally.
2727

2828
```python
@@ -37,7 +37,7 @@ def f():
3737
return os.path.join("a", "b")
3838
```
3939

40-
### I2001
40+
### IMR201
4141
Alias identifiers defined from `as` segments should be at
4242
least two characters long.
4343

@@ -49,7 +49,7 @@ import os.path as p
4949
import os.path as path
5050
```
5151

52-
### I2002
52+
### IMR202
5353
Alias identifiers should not have the same name as the imported object.
5454

5555
```python
@@ -62,7 +62,7 @@ import sys
6262

6363
## `import` Syntax Errors
6464

65-
### I2020
65+
### IMR220
6666
When using the `import` syntax, if the imported module is a submodule,
6767
i.e. not a top level module, an `as` segment should be present.
6868

@@ -75,7 +75,7 @@ import sys
7575
import os.path as path
7676
```
7777

78-
### I2021
78+
### IMR221
7979
When using the `import` syntax, each import statement should
8080
only import one module.
8181

@@ -88,11 +88,11 @@ import sys
8888
import os
8989
```
9090

91-
### I2022
91+
### IMR222
9292
The `import` syntax should not be used.
9393

9494

95-
### I2023
95+
### IMR223
9696
When using the `import` syntax, do not duplicate module names in the `as`
9797
segment.
9898

@@ -108,7 +108,7 @@ import os.path as ospath
108108

109109
## `from` Syntax Errors
110110

111-
### I2040
111+
### IMR240
112112
When using the `from` syntax, the `import` segment only contains one
113113
import.
114114

@@ -121,7 +121,7 @@ from os import path
121121
from os import environ
122122
```
123123

124-
### I2041
124+
### IMR241
125125
When using the `from` syntax, only submodules are imported, not
126126
module elements.
127127

@@ -133,7 +133,7 @@ from os.path import join
133133
from os import path
134134
```
135135

136-
### I2042
136+
### IMR242
137137
When using the `from` syntax, only module elements are imported,
138138
not submodules.
139139

@@ -145,7 +145,7 @@ from os import path
145145
from os.path import join
146146
```
147147

148-
### I2043
148+
### IMR243
149149
When using the `from` syntax, `import *` should not be used.
150150

151151
```python
@@ -156,7 +156,7 @@ from os.path import *
156156
from os.path import join
157157
```
158158

159-
### I2044
159+
### IMR244
160160
Relative imports should not be used.
161161

162162
```python
@@ -167,5 +167,5 @@ from . import foo
167167
from flake8_import_restrictions import foo
168168
```
169169

170-
### I2045
170+
### IMR245
171171
The `from` syntax should not be used.

0 commit comments

Comments
 (0)