Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
535a689c
Unverified
Commit
535a689c
authored
3 years ago
by
David Robertson
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reintroduce the lint targets in the linter script (#12455)
parent
6b3e0ea6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/12455.misc
+1
-0
1 addition, 0 deletions
changelog.d/12455.misc
docs/code_style.md
+15
-39
15 additions, 39 deletions
docs/code_style.md
scripts-dev/lint.sh
+14
-2
14 additions, 2 deletions
scripts-dev/lint.sh
with
30 additions
and
41 deletions
changelog.d/12455.misc
0 → 100644
+
1
−
0
View file @
535a689c
Reintroduce the list of targets to the linter script, to avoid linting unwanted local-only directories during development.
This diff is collapsed.
Click to expand it.
docs/code_style.md
+
15
−
39
View file @
535a689c
...
@@ -6,60 +6,36 @@ The Synapse codebase uses a number of code formatting tools in order to
...
@@ -6,60 +6,36 @@ The Synapse codebase uses a number of code formatting tools in order to
quickly and automatically check for formatting (and sometimes logical)
quickly and automatically check for formatting (and sometimes logical)
errors in code.
errors in code.
The necessary tools are
detailed below.
The necessary tools are
:
First install them with:
-
[
black
](
https://black.readthedocs.io/en/stable/
)
, a source code formatter;
-
[
isort
](
https://pycqa.github.io/isort/
)
, which organises each file's imports;
-
[
flake8
](
https://flake8.pycqa.org/en/latest/
)
, which can spot common errors; and
-
[
mypy
](
https://mypy.readthedocs.io/en/stable/
)
, a type checker.
Install them with:
```
sh
```
sh
pip
install
-e
".[lint,mypy]"
pip
install
-e
".[lint,mypy]"
```
```
-
**black**
The easiest way to run the lints is to invoke the linter script as follows.
The Synapse codebase uses [black](https://pypi.org/project/black/)
as an opinionated code formatter, ensuring all comitted code is
properly formatted.
Have `black` auto-format your code (it shouldn't change any
functionality) with:
```sh
black .
```
-
**flake8**
`flake8` is a code checking tool. We require code to pass `flake8`
before being merged into the codebase.
Check all application and test code with:
```sh
```
sh
flake8 .
scripts-dev/lint.sh
```
```
-
**isort**
`isort` ensures imports are nicely formatted, and can suggest and
auto-fix issues such as double-importing.
Auto-fix imports with:
```sh
isort .
```
It's worth noting that modern IDEs and text editors can run these tools
It's worth noting that modern IDEs and text editors can run these tools
automatically on save. It may be worth looking into whether this
automatically on save. It may be worth looking into whether this
functionality is supported in your editor for a more convenient
functionality is supported in your editor for a more convenient
development workflow. It is not, however, recommended to run
`flake8`
o
n
development workflow. It is not, however, recommended to run
`flake8`
o
r
`mypy`
save as
i
t take
s
a while and
is
very resource intensive.
on
save as t
hey
take a while and
can be
very resource intensive.
## General rules
## General rules
-
**Naming**
:
-
**Naming**
:
-
Use
c
amel
c
ase for class and type names
-
Use
`C
amel
C
ase
`
for class and type names
-
Use underscores for function
s
and variable
s
.
-
Use underscores for
`
function
_names`
and
`
variable
_names`
.
-
**Docstrings**
: should follow the
[
google code
-
**Docstrings**
: should follow the
[
google code
style
](
https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
)
.
style
](
https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
)
.
See the
See the
...
...
This diff is collapsed.
Click to expand it.
scripts-dev/lint.sh
+
14
−
2
View file @
535a689c
...
@@ -79,8 +79,20 @@ else
...
@@ -79,8 +79,20 @@ else
# If we were not asked to lint changed files, and no paths were found as a result,
# If we were not asked to lint changed files, and no paths were found as a result,
# then lint everything!
# then lint everything!
if
[[
-z
${
files
+x
}
]]
;
then
if
[[
-z
${
files
+x
}
]]
;
then
# Lint all source code files and directories
# CI runs each linter on the entire checkout, e.g. `black .`. So don't
files
=(
"."
)
# rely on this list to *find* lint targets if that misses a file; instead;
# use it to exclude files from linters when this can't be done by config.
#
# To check which files the linters examine, use:
# black --verbose . 2>&1 | \grep -v ignored
# isort --show-files .
# flake8 --verbose . # This isn't a great option
# mypy has explicit config in mypy.ini; there is also mypy --verbose
files
=(
"synapse"
"docker"
"tests"
"scripts-dev"
"contrib"
"setup.py"
"synmark"
"stubs"
".ci"
)
fi
fi
fi
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment