Skip to content

Commit

Permalink
Package updates (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apakottur authored May 16, 2024
1 parent d114915 commit dca3001
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install pre-commit requirements
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist

# Temporary files
tmp
.cspellcache
38 changes: 24 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
default_language_version:
python: python3.11
python: python3.12
repos:
###########
# GENERAL #
###########
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ["--maxkb=2000"]
Expand Down Expand Up @@ -47,12 +47,24 @@ repos:
hooks:
- id: taplo-docker
args: [format, --config, ./linters/taplo.toml]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: ['--config-file', './linters/yamllint.yaml']
- repo: https://github.com/biomejs/pre-commit
rev: v0.1.0
hooks:
- id: biome-check
args: [--config-path, ./linters]
additional_dependencies: ["@biomejs/biome@1.5.1"]
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.8.1
hooks:
- id: cspell
exclude: \.(csv|json|txt|lock)$
args: ["lint", "-c", "./linters/cspell.json", "--no-progress",
"--cache", "--cache-location", "./linters/.cspellcache"]
##########
# PYTHON #
##########
Expand All @@ -62,7 +74,6 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- repo: https://github.com/MarcoGorelli/absolufy-imports
Expand All @@ -72,30 +83,29 @@ repos:
types: [file]
types_or: [python, pyi]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.4.4
hooks:
- id: ruff
args: [ --config, ./linters/ruff.toml ]
args: [--config, ./linters/ruff.toml]
- id: ruff-format
args: [ --config, ./linters/ruff.toml ]

args: [--config, ./linters/ruff.toml]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==24.2.6
- flake8-bugbear==24.4.26
- flake8-comprehensions==3.14.0
- flake8-picky-parentheses==0.5.4
- flake8-pyi==24.1.0
- flake8-picky-parentheses==0.5.5
- flake8-pyi==24.4.1
- pep8-naming==0.13.3
- pydoclint==0.4.0
- pydoclint==0.4.1
args: [--config, ./linters/.flake8]
types: [file]
types_or: [python, pyi]
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- id: darglint
- repo: https://github.com/jendrikseipp/vulture
rev: v2.11
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Use `shpyx.run` to run a shell command in a subprocess:

```python
>>> import shpyx
>>> shpyx.run("echo 1")
ShellCmdResult(cmd='echo 1', stdout='1\n', stderr='', all_output='1\n', return_code=0)
>>> shpyx.run("echo 1").return_code
0
>>> shpyx.run("echo 1").stdout
'1\n'
>>> shpyx.run("echo 1").stderr
''
>>> shpyx.run("echo 1")
ShellCmdResult(cmd='echo 1', stdout='1\n', stderr='', all_output='1\n', return_code=0)
```

## Installation
Expand Down Expand Up @@ -168,10 +168,11 @@ Relevant Python libraries:
- [subprocess](https://docs.python.org/3/library/subprocess.html)
- [shlex](https://docs.python.org/3/library/shlex.html)

Other user libraries for running shell commands in Python:
Other 3rd-party libraries for running shell commands in Python:

- [sarge](https://github.com/vsajip/sarge)
- [sh](https://github.com/amoffat/sh)
- [invoke](https://github.com/pyinvoke/invoke)

## Contributing

Expand Down
26 changes: 8 additions & 18 deletions linters/.flake8
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
[flake8]
per-file-ignores =
#################################
# Ignore warnings in stub files #
#################################
*.pyi:
# Multiple statements on one line
E701,
# Class name 'geodesic' should use CapWords convention
N801,
# Function name X should be lowercase
N802,
# Argument name X should be lowercase
N803,
# Variable X in class scope should not be mixedCase
N815,
# Only operators and comments are allowed after a closing bracket on a new line
PAR104

# Enable everything by default.
select = A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z

ignore =
################################################
# Ignored - we rely on ruff to format our code #
################################################
# Whitespace after '{'
E201
# Whitespace before '}'
E202
# Whitespace before ':'
E203
# At least two spaces before inline comment
Expand Down Expand Up @@ -51,6 +37,10 @@ ignore =
# Unnecessary generator
C401
# Unnecessary list comprehension
C403
# Unnecessary set comprehension
C416
# Unnecessary list comprehension
C419
# Module level import not at top of file
E402
Expand Down
10 changes: 10 additions & 0 deletions linters/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dictionaries": ["custom-words"],
"dictionaryDefinitions": [
{
"name": "custom-words",
"path": "./cspell/words.txt",
"addWords": true
}
]
}
41 changes: 41 additions & 0 deletions linters/cspell/words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
shpyx
pytest
mypy
taplo
shlex
popen
setfl
getfl
nonblock
capfd
isort
elif
numpy
classmethod
darglint
pydoclint
absolufy
pydocstyle
shfmt
shellcheck
biomejs
noqa
shellcheck
Yossi
Rozantsev
psql
fcntl
pyproject
autofixing
unfixable
contextlib
docstrings
pydantic
builtins
addopts
venv
pycache
pypi
ignorelist
pythonpath
subclassing
28 changes: 12 additions & 16 deletions linters/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
line-length = 120

# Python version.
target-version = "py38"
target-version = "py312"

# Enable autofixing.
fix = true

[format]
# Enable everything by default.
preview = true
# Preview mode is unstable and should not be used.
preview = false

quote-style = "double"
indent-style = "space"


[lint]
# Enable everything by default.
preview = true
# Preview mode is unstable and should not be used.
preview = false

# Enable everything else.
select = ["ALL"]
fixable = ["ALL"]
unfixable = []
Expand All @@ -31,7 +34,6 @@ ignore = [
# Ignored - Conflicts with Ruff formatter #
###########################################
"COM812", # Trailing comma missing
"E203", # Whitespace before ':'
"E501", # Line too long
"ISC001", # Implicitly concatenated string literals on one line
##############
Expand All @@ -58,42 +60,36 @@ ignore = [
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"BLE001", # Do not catch blind exception: `Exception`
"C901", # Method is too complex
"CPY001", # Missing copyright notice at top of file
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"ERA001", # Found commented-out code
"FIX002", # Line contains TODO
"FURB101", # Replace `read` and `open` by `pathlib` methods.
"ISC003", # Explicitly concatenated string should be implicitly concatenate
"N818", # Exception name should be named with an Error suffix
"PD011", # Use `.to_numpy()` instead of `.values`
"PLR0904", # Too many public methods
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments to function call
"PLR0914", # Too many local variables
"PLR0915", # Too many statements
"PLR0917", # Too many positional arguments
"PLR1722", # Use `sys.exit()` instead of `exit`
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"PLR5501", # Consider using `elif` instead of `else` then `if` to remove one indentation level
"PLR6301", # Method X could be a function or static method
"PLW1514", # `open` in text mode without explicit `encoding` argument
"PTH123", # `open()` should be replaced by `Path.open()`
"RET505", # Unnecessary `else` after `return` statement
"RET506", # Unnecessary `else` after `raise` statement
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM105", # Use `contextlib.suppress()` instead of try-except-pass
"TCH001", # Move application import into a type-checking block
"TCH002", # Move third-party import into a type-checking block
"TCH003", # Move standard library import into a type-checking block
"TD002", # Missing author in TODO
"TD003", # Missing issue link on the line following this TODO
"TD005", # Missing issue description after `TODO`
"TRY003", # Avoid specifying long messages outside the exception class
]

[lint.isort]
# Import sorting configuration.
isort = {combine-as-imports = true}
split-on-trailing-comma = false
combine-as-imports = true

[lint.pydocstyle]
# Use Google-style docstrings.
Expand Down
19 changes: 19 additions & 0 deletions linters/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends: default

rules:
line-length:
max: 120

document-start:
present: false


comments:
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 1


truthy:
allowed-values: ['true', 'false', 'on', 'off']
check-keys: true
Loading

0 comments on commit dca3001

Please sign in to comment.