Skip to content

Commit 00d46a8

Browse files
authored
Merge pull request seed-labs#271 from netsys-lab/feature/linter
Add linters and code formatter
2 parents b881c62 + 90351ed commit 00d46a8

File tree

6 files changed

+64
-17
lines changed

6 files changed

+64
-17
lines changed

.flake8

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[flake8]
2+
# maximum recommended by PEP 8 is 99
3+
max-line-length = 99
4+
# maximum recommended by PEP 8 is 72
5+
max-doc-length = 80
6+
7+
ignore =
8+
# disable warnings that conflict with Black
9+
E203
10+
E701
11+
12+
exclude =
13+
.git
14+
.venv
15+
client
16+
docker_images
17+
docs
18+
__pycache__
19+
output
20+
21+
per-file-ignores =
22+
# Ignore unused star imports in __init__ files
23+
__init__.py:F401,F403

CONTRIBUTING.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,52 @@ figure out where you can best be helpful.
1212

1313
## How to Contribute
1414

15-
- **Adding new elements**. We will be actively developing new elements
15+
- **Adding new elements**. We will be actively developing new elements
1616
useful for Internet emulation. For example, recently we have added
1717
DNS, Botnet, Darknet components, and we are currently developing blockchain
18-
components. It is these components that will make the emulator
19-
more interesting and more useful.
18+
components. It is these components that will make the emulator
19+
more interesting and more useful.
2020

21-
- **Improving existing elements**: Some of the elements are currently quite rudimentary, and
22-
rich features need to be added. You can help us propose and implement
23-
new features to those elements.
21+
- **Improving existing elements**: Some of the elements are currently quite rudimentary, and
22+
rich features need to be added. You can help us propose and implement
23+
new features to those elements.
2424

25-
- **Building more complicated emulation**: The Internet emulators built by the
25+
- **Building more complicated emulation**: The Internet emulators built by the
2626
current examples included in the project are quite small. It will be useful if we can build
2727
more complicated examples, and share them as components, so others
2828
can use these components to build their emulators. In the future, we can
29-
create a market place so people can share or trade their emulators.
29+
create a market place so people can share or trade their emulators.
3030

31-
- **Testing**. We definitely need more people to help test
31+
- **Testing**. We definitely need more people to help test
3232
the code and provide feedback. You can create issues to tell us
3333
about the bugs and feedback.
34-
35-
- **Developing lab exercises**. The emulator created from this project is
34+
35+
- **Developing lab exercises**. The emulator created from this project is
3636
intended for being used as a platform for lab exercises, especially in
3737
the field of cybersecurity and networking. The proposed lab ideas
3838
can be found in the [labs/](./labs/) folder. You can help develop
39-
these labs or propose new ideas.
39+
these labs or propose new ideas.
40+
41+
## Running Linters and Code Formatters
4042

43+
- **flake8** checks compliance with the PEP 8 style guide. You can invoke it
44+
globally by running `flake8` in the root of the repository or pass individual
45+
files to check. If you are using VS Code, there is also a flake8 plugin
46+
running the linter continuously in the background.
47+
- **black** formats files or sections of code to comply with its style guideline
48+
and should fix most formatting errors that flake8 points out. You can invoke
49+
`black` on the command line with the path to a file to format. There are also
50+
editor plugins that allow formatting code selections easily.
51+
- **mypy** is a static type checker that makes sure Python type annotations are
52+
correct. Running `mypy` in the root of the repository checks all modules in
53+
`seedemu`. See the [mypy documentation][mypy-cli] on how to check individual
54+
files or modules on the command line.
55+
56+
[mypy-cli]: https://mypy.readthedocs.io/en/stable/command_line.html
4157

4258
## Community
4359

44-
Discussions about the Open Source Guides take place on
45-
this repository's [Issues](https://github.com/seed-labs/SEEDEmulator/issues) and [Pull Requests](https://github.com/seed-labs/SEEDEmulator/pulls) sections. Anybody is welcome to join these conversations.
60+
Discussions about the Open Source Guides take place on
61+
this repository's [Issues](https://github.com/seed-labs/SEEDEmulator/issues) and [Pull Requests](https://github.com/seed-labs/SEEDEmulator/pulls) sections. Anybody is welcome to join these conversations.
4662

4763
Wherever possible, do not take these conversations to private channels, including contacting the maintainers directly. Keeping communication public means everybody can benefit and learn from the conversation.
48-

dev-requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black==25.1.0
2+
flake8==7.1.2
3+
mypy==1.15.0
4+
mypy-extensions==1.0.0

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
packages = seedemu

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.black]
2+
target-version = ["py38", "py39", "py310"]
3+
line-length = 99

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
eth_account==0.5.9
2-
requests==2.22.0
32
eth-rlp<0.3
4-
web3==5.31.1
53
PyYAML==6.0.1
4+
requests==2.22.0
5+
web3==5.31.1

0 commit comments

Comments
 (0)