Skip to content

Commit

Permalink
Set up mini package
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius1311 committed Apr 24, 2024
1 parent 585c541 commit aecc276
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[makefile]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ figures/

# R stuff
*.Rhistory

.vscode/*
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
fail_fast: false
default_language_version:
python: python3
default_stages:
- commit
- push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black-jupyter
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
# Newer versions of node don't work on systems that have an older version of GLIBC
# (in particular Ubuntu 18.04 and Centos 7)
# EOL of Centos 7 is in 2024-06, we can probably get rid of this then.
# See https://github.com/scverse/cookiecutter-scverse/issues/143 and
# https://github.com/jupyterlab/jupyterlab/issues/12675
language_version: "17.9.1"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.253
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: detect-private-key
- id: check-ast
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
- id: check-case-conflict
- repo: local
hooks:
- id: forbid-to-commit
name: Don't commit rej files
entry: |
Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates.
Fix the merge conflicts manually and remove the .rej files.
language: fail
files: '.*\.rej$'
Empty file removed data/.gitkeep
Empty file.
114 changes: 114 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[build-system]
requires = ['setuptools', 'setuptools_scm']
build-backend = 'setuptools.build_meta'

[project]
name = "fancypackage"
version = "0.0.0"
description = "Fancy Package"
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{name = "Jane Doe"},
]
maintainers = [
{name = "Jane Doe", email = "[email protected]"},
]
urls.Source = "https://github.com/url/to/repo.git"
urls.Home-page = "https://github.com/url/to/repo.git"
dependencies = [
"anndata",
"scanpy",
]

[project.optional-dependencies]
dev = [
"pre-commit",
]

[tool.black]
line-length = 120
include = '\.pyi?$|\.ipynb?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
'''

[tool.isort]
profile = "black"
use_parentheses = true
known_num = "networkx,numpy,pandas,scipy,sklearn,statmodels"
known_plot = "matplotlib,mplscience,mpl_toolkits,seaborn"
known_bio = "anndata,scanpy"
sections = "FUTURE,STDLIB,THIRDPARTY,NUM,PLOT,BIO,FIRSTPARTY,LOCALFOLDER"
no_lines_before = "LOCALFOLDER"
balanced_wrapping = true
length_sort = "0"
indent = " "
float_to_top = true
order_by_type = false

[tool.ruff]
src = ["."]
line-length = 119
target-version = "py38"
select = [
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
"C4", # flake8-comprehensions
"BLE", # flake8-blind-except
"UP", # pyupgrade
"RUF100", # Report unused noqa directives
]
ignore = [
# line too long -> we accept long comment lines; black gets rid of long code lines
"E501",
# Do not assign a lambda expression, use a def -> lambda expression assignments are convenient
"E731",
# allow I, O, l as variable names -> I is the identity matrix
"E741",
# Missing docstring in public package
"D104",
# Missing docstring in public module
"D100",
# Missing docstring in __init__
"D107",
# Errors from function calls in argument defaults. These are fine when the result is immutable.
"B008",
# __magic__ methods are are often self-explanatory, allow missing docstrings
"D105",
# first line should end with a period [Bug: doesn't work with single-line docstrings]
"D400",
# First line should be in imperative mood; try rephrasing
"D401",
## Disable one in each pair of mutually incompatible rules
# We don’t want a blank line before a class docstring
"D203",
# We want docstrings to start immediately after the opening triple quote
"D213",
# Missing argument description in the docstring TODO: enable
"D417",
# Unable to detect undefined names
"F403",
# Underfined, or defined from star imports: module
"F405",
# Within an except clause, raise exceptions with `raise ... from err`
"B904",
]
3 changes: 3 additions & 0 deletions src/fancypackage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .core import DATA_DIR, FIG_DIR

__all__ = ["DATA_DIR", "FIG_DIR"]
3 changes: 3 additions & 0 deletions src/fancypackage/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._constants import DATA_DIR, FIG_DIR

__all__ = ["DATA_DIR", "FIG_DIR"]
4 changes: 1 addition & 3 deletions paths.py → src/fancypackage/core/_constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from pathlib import Path

ROOT = Path(__file__).parent.resolve()
ROOT = Path(__file__).parents[3].resolve()


DATA_DIR = ROOT / "data"
FIG_DIR = ROOT / "figures"
CODE_DIR = ROOT / "src"

Empty file removed src/utils/.gitkeep
Empty file.

0 comments on commit aecc276

Please sign in to comment.