@@ -3,24 +3,24 @@ Coding Standards
3
3
4
4
Code Style
5
5
----------
6
- `Black ` is a PEP-8 compliant opinionated formatter.
6
+ `` Black ` ` is a PEP-8 compliant opinionated formatter.
7
7
8
8
> https://github.com/psf/black
9
9
10
- We philosophically agree with the `Black ` formatting style, however it does not
10
+ We philosophically agree with the `` Black ` ` formatting style, however it does not
11
11
currently run over Cython code. So you could say we are "handcrafting towards"
12
- `Blacks ` stylistic conventions.
12
+ `` Blacks ` ` stylistic conventions.
13
13
14
14
The current codebase can be used as a guide for formatting guidance.
15
15
16
- - For longer lines of code, and when passing more than a couple of arguments -
16
+ - For longer lines of code, and when passing more than a couple of arguments
17
17
it's common to take a new line which aligns at the next logical indent (rather
18
18
than attempting a hanging alignment off an opening parenthesis).
19
19
20
20
- The closing parenthesis should be located on a new line, aligned at the logical
21
21
indent.
22
22
23
- - Also ensure multiple hanging parameters or arguments end with a comma ` , ` ::
23
+ - Also ensure multiple hanging parameters or arguments end with a comma::
24
24
25
25
LongCodeLine(
26
26
some_arg1,
@@ -34,22 +34,22 @@ PEP-8
34
34
The codebase generally follows the PEP-8 style guide.
35
35
36
36
One notable departure is that Python `truthiness ` is not always taken advantage
37
- of to check if an argument is `None `, or if a collection is empty/has elements.
37
+ of to check if an argument is `` None ` `, or if a collection is empty/has elements.
38
38
39
39
There are two reasons for this;
40
40
41
- 1- Cython can generate more efficient C code from `is None ` and `is not None `,
42
- rather than entering the Python runtime to check the `PyObject ` truthiness.
41
+ 1- Cython can generate more efficient C code from `` is None `` and `` is not None ` `,
42
+ rather than entering the Python runtime to check the `` PyObject ` ` truthiness.
43
43
44
44
2- As per the `Google Python Style Guide ` it's discouraged to use truthiness to
45
45
check if an argument is/is not None, when there is a chance an unexpected object
46
46
could be passed into the function or method which will yield an unexpected
47
47
truthiness evaluation - which could result in a logical error type bug.
48
48
49
- _ "Always use if foo is None: (or is not None) to check for a None value.
49
+ "Always use if foo is None: (or is not None) to check for a None value.
50
50
E.g., when testing whether a variable or argument that defaults to None was set
51
51
to some other value. The other value might be a value that’s false in a boolean
52
- context!"_
52
+ context!"
53
53
54
54
> https://google.github.io/styleguide/pyguide.html
55
55
@@ -64,22 +64,22 @@ NumPy Docstrings
64
64
----------------
65
65
The NumPy docstring syntax is used throughout the codebase. This needs to be
66
66
adhered to consistently to ensure the docs build correctly during pushes to the
67
- `master ` branch.
67
+ `` master ` ` branch.
68
68
69
69
> https://numpydoc.readthedocs.io/en/latest/format.html
70
70
71
71
Flake8
72
72
------
73
- `flake8 ` is utilized to lint the codebase. Current ignores can be found in the
74
- `.flake8 ` config file, the majority of which are required so that valid Cython
73
+ `` flake8 ` ` is utilized to lint the codebase. Current ignores can be found in the
74
+ `` .flake8 ` ` config file, the majority of which are required so that valid Cython
75
75
code is not picked up as flake8 failures.
76
76
77
77
Cython
78
78
------
79
- Ensure that all functions and methods returning `void ` or a primitive C type
80
- (such as `bint `, `int `, `double `) include the `except * ` keyword in the signature.
79
+ Ensure that all functions and methods returning `` void ` ` or a primitive C type
80
+ (such as `` bint `` , `` int `` , `` double `` ) include the `` except * ` ` keyword in the signature.
81
81
82
- This will ensure Python exceptions are not ignored, but instead are ` bubbled up `
82
+ This will ensure Python exceptions are not ignored, but instead are " bubbled up"
83
83
to the caller as expected.
84
84
85
85
More information on Cython syntax and conventions can be found by reading the
0 commit comments