Comments (3)
I support this!
The linters I use are: mypy
(git version), prospector
(pylint
+ pep8
+ McCabe complexity
) and pydocstyle
. The formatters I use are: isort
and autopep8
.
The latest release of mypy
(December 2020) strangely doesn't like the list[subtype]
syntax, even after including from __future__ import annotations
. I therefore use the latest source version instead, which has included a fix (pip install git+https://github.com/python/mypy.git
).
Linters
mypy is a static type helper, for example giving an error if you write def func(value: int = 1.1) -> float
(1.1 is not an int), or try to subsequently use the function in an incorrect manner: "hello" + func(3)
(str + float doesn't work).
pydocstyle makes sure docstrings are more or less correctly formatted. It doesn't enforce e.g. sphinx formatting, so maybe there's another tool to add here?
prospector is a convenience linter that implements three linters in one:
pylint is a general-purpose linter for common issues. For example, it enforces the correct use of "snake_case" and "CamelCase" naming conventions.
pep8 warns you about line lengths, weird whitespace, wrong indentation, correct line spacing between functions, etc.
McCabe complexity makes sure that functions and classes are not overly complex, e.g. if a function has more than X defined variables, maybe it should be split in two. I am particularly bad at this..
Formatters
isort sorts imports alphabetically and divides them in three categories: "builtin imports", "third party imports", "local imports" (if the import is a directory in your cwd for example).
autopep8 helps with automatically conforming your code to the pep8 standard.
I've set the autopep8
and pylint
maximum column width to 120 lines instead of 80 (read Linus Torvalds' take on this!)
Should we agree on a combination of linters and formatters? I know some repos have commit/push/merge hooks that format the code. Since we are only ~three active developers right now, maybe this is overly complex at the time being, but we could consider something similar in the future.
from xdem.
Maybe the issue should be renamed "Write a contribution guideline" with all this info ;-)
https://docs.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors
from xdem.
This is amazing @erikmannerfelt ! 😳
Learning a great lot thanks to you.
Should we agree on a combination of linters and formatters? I know some repos have commit/push/merge hooks that format
the code. Since we are only ~three active developers right now, maybe this is overly complex at the time being, but we could
consider something similar in the future.
I agree that this is still early. It would be great for us three to try to abide by those standards, which are really useful even for us when coding (in PyCharm, I simply point my mouse at a function I'm using and I get all input/output types in detail, it's truly amazing), and to make everything homogeneous.
#56 will be super helpful, even for the next GlacioHack.
I guess we should aim at switching the annotations of geoutils too, for consistency? It's good practice too ;)
from xdem.
Related Issues (20)
- Remove legacy NumPy random number generator
- Clarify which angle is needed for DirectionalBias HOT 1
- Add function `Coreg.run()` or `Coreg.fit_and_apply()` to run both `fit()` and `apply()` steps simultaneously
- Remove classes `Bias1D`, `Bias2D` in favor of a `nd` argument defined on instantiation?
- Make `DEM.to_vcrs()` not inplace by default
- Improve `fit.robust_nfreq_sumsin_fit()` with fast fourier transform?
- Fix error with `robust_nfreq_sumsin_fit()` in CI
- Coverage error in CI HOT 1
- Unpin `coverage<7` in CI once `coveragepy-lcov` fixed
- Test in `test_biascorr` fails randomly with optimizer error
- Collect references of projects using xdem HOT 1
- Update coreg examples to use `fit_and_apply`
- Homogenize typing between xDEM and GeoUtils
- Speed-up tests of pipeline combinations using `subsample` with `random_state`
- Test `Coreg` module with `DEM` inputs instead of `Raster`
- Generalize `scipy.interpolate.RectBivariateSpline` into any regular grid interpolator in `NuthKaab` for consistent package-wide resampling
- Optimize coregistration module performance for Xarray/Raster objects
- Improve 1d binning plots HOT 2
- Bug with raster-point coregistration HOT 1
- Rename `Coreg.meta` into a clearer naming before documenting it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xdem.