Skip to content

Commit

Permalink
Py open sci review (#89)
Browse files Browse the repository at this point in the history
* Implementing suggested ruff rules

* isort

* Fix whitespace (many of these were copied from docs example execution - need to confirm it passes docs tests)

* Run test.yml on push to this branch

* Whitespace

* F401 (redundant alias)

* Missed whitespace

* First attempt w/ pre-commit

* Fix indent

* indent/drop name

* Rename .pre-commit-config.yml to .pre-commit-config.yaml

yAml

* Update .pre-commit-config.yaml

fix file structure

* Reduce .pre-commit-config.yaml

Reduce what files it is run on

* Update domains.py

Doesn't need to be raw string (see Batalex pyOpenSci/software-submission#157 (comment))

* Dict doc strings as module level attributes

* Update to main (#88)

* Update domains.py

'Field' -> 'Field***'

* 62   r test ci (#86)

Update test_r.yaml to install conda outside r, specifically miniforge, then run on env from setup with current package (vs pip installing main)

* Update .pre-commit-config.yaml

From issue: pass_filenames: false in the pre-commit config so that the file discovery is done by Ruff taking into account the includes and excludes configured by the user in their pyproject.toml

* Update .pre-commit-config.yaml

Try updating to patch version and specify config in args.

* Update pyproject.toml

try withouth 'docstring-code-format = true' as this may override other settings.

* Update pyproject.toml

Try to get pre-commit to see config

* Update pyproject.toml

Warning message, so it is getting these settings from the toml?

* Update conf.py

E501

* Update basis.py

E501

* Update basis.py

Moved constant doc-string to module level

* Update clean.py

E501

* Update convert.py

E501

* Update conf.py

lint/format edits

* Update pyproject.toml

Without single checking if double is default

* Update pyproject.toml

Will move to one or the other (likely default double for ease), but trying to post-pone to work through diff

* lint/formating

* linted

* W293

* black format/lint

* W605 - try pulling r str out of test doc-string and instead as a comment. Comment shouldn't cause problems but this one has in the past.

* I001 (all whitespace except test_harmonize_WQP.py)

* lint conf file

* lint

* Add white space between module doc-string and imports

* Format: add whitespace after mod doc-string

* Add assert for actual2 - where the characteristics specific function is used instead of the generic.

* Resolved some E501

* Check if new line fails doctest

* Revert to get doc-test passing

* Spread out example df entry

* Spread out dict read out to reduce line length. White space is already normalized for doc-test so this may pass.

* Revert

* Spread out building df for wq_dat.WQCharData example.

* spread out example df for we_date.measure_mask()

* Shotern len of dict for wq_data.replace_unit_str() & wq_data.apply_conversion() examples

* Attempt to skip E501 on this line

* skip rule on line

* Last attempt to ignore line too long in docstrings (3)

* Update pyproject.toml

Drop single quote for lint

* '' -> ""

* Update test.yml

Revert back to testing on main only
  • Loading branch information
jbousquin authored Aug 3, 2024
1 parent f4f53b7 commit 878a29f
Show file tree
Hide file tree
Showing 16 changed files with 1,923 additions and 1,696 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: lint

on:
push:
branches:
[pyOpenSci-review]
pull_request:
branches:
[pyOpenSci-review]


jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- uses: pre-commit/[email protected]
with:
extra_args: --all-files --show-diff-on-failure
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: test
on:
push:
branches:
[main, dev]
[main]
pull_request:
branches:
[main]
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes", --config=pyproject.toml]
- id: ruff-format
61 changes: 33 additions & 28 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
# If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import doctest
import os
import sys
import doctest

sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("../.."))

#from importlib.metadata import version
#import harmonize_wq
# from importlib.metadata import version
# import harmonize_wq

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'harmonize_wq'
copyright = '2023, US Environmental Protection Agency'
author = 'Justin Bousquin (US Environmental Protection Agency)'
project = "harmonize_wq"
copyright = "2023, US Environmental Protection Agency"
author = "Justin Bousquin (US Environmental Protection Agency)"

# ToDO:single source version
version = "0.4.0"
#release = version(project)
#release = harmonize_wq.__version__
#version = '.'.join(release.split('.')[:2])
# release = version(project)
# release = harmonize_wq.__version__
# version = ".".join(release.split(".")[:2])


# -- General configuration ---------------------------------------------------
Expand All @@ -49,10 +49,12 @@
]

autosummary_generate = True # Turn on sphinx.ext.autosummary
html_show_sourcelink = False # Remove 'view source code' from top of page (for html, not python)

templates_path = ['_templates']
exclude_patterns = ['_build', '_templates']
# Remove "view source code" from top of page (for html, not python)
html_show_sourcelink = False

templates_path = ["_templates"]
exclude_patterns = ["_build", "_templates"]


# -- Options for HTML output -------------------------------------------------
Expand All @@ -62,29 +64,32 @@
html_static_path = []

# Readthedocs theme (may be useful for actions)
# on_rtd is whether on readthedocs.org, this line of code grabbed from docs.readthedocs.org...
#on_rtd = os.environ.get("READTHEDOCS", None) == "True"
#if not on_rtd: # only import and set the theme if we're building docs locally
# This line from docs.readthedocs.org, on_rtd is whether on readthedocs.org
# on_rtd = os.environ.get("READTHEDOCS", None) == "True"
# if not on_rtd: # only import and set the theme if we're building docs locally
# import sphinx_rtd_theme
# html_theme = "sphinx_rtd_theme"
# html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
#html_css_files = ["readthedocs-custom.css"] # Override some CSS settings
# html_css_files = ["readthedocs-custom.css"] # Override some CSS settings


# -- Options for doctest ------------------------------------------------------
# default to ignoring whitespace
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)

# Should enable IGNORE_RESULT option
IGNORE_RESULT = doctest.register_optionflag('IGNORE_RESULT')
IGNORE_RESULT = doctest.register_optionflag("IGNORE_RESULT")

OutputChecker = doctest.OutputChecker


class CustomOutputChecker(OutputChecker):
def check_output(self, want, got, optionflags):
if IGNORE_RESULT & optionflags:
return True
return OutputChecker.check_output(self, want, got, optionflags)


doctest.OutputChecker = CustomOutputChecker

# -- Options for Napolean output ----------------------------------------------
Expand All @@ -99,10 +104,10 @@ def check_output(self, want, got, optionflags):

# -- Options for sphinx-contrib\apidoc ----------------------------------------
# NOT currently using apidoc
#apidoc_separate_modules = True
#apidoc_module_dir = "../harmonize_wq"
#apidoc_excluded_paths = ["tests"]
#apidoc_module_first = True
# apidoc_separate_modules = True
# apidoc_module_dir = "../harmonize_wq"
# apidoc_excluded_paths = ["tests"]
# apidoc_module_first = True

# -- Options for sphinxcontrib-spelling ---------------------------------------
spelling_lang = "en_US"
Expand All @@ -123,25 +128,25 @@ def check_output(self, want, got, optionflags):
"dataretrieval": (
"https://doi-usgs.github.io/dataretrieval-python/",
"https://doi-usgs.github.io/dataretrieval-python/objects.inv",
),
),
"pint": (
"https://pint.readthedocs.io/en/stable/",
"https://pint.readthedocs.io/en/stable/objects.inv",
),
),
"geopandas": (
"https://geopandas.org/en/stable/",
"https://geopandas.org/en/stable/objects.inv",
),
),
"pandas": (
"https://pandas.pydata.org/pandas-docs/stable/",
"https://pandas.pydata.org/pandas-docs/stable/objects.inv",
),
),
"pyproj": (
"https://pyproj4.github.io/pyproj/stable/",
"https://pyproj4.github.io/pyproj/stable/objects.inv",
),
),
"python": (
"https://docs.python.org/3",
"https://docs.python.org/3/objects.inv",
),
}
),
}
7 changes: 4 additions & 3 deletions harmonize_wq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from harmonize_wq import harmonize
from importlib.metadata import version, PackageNotFoundError
from importlib.metadata import PackageNotFoundError, version

from harmonize_wq import harmonize as harmonize

try:
__version__ = version('harmonize_wq')
__version__ = version("harmonize_wq")
except PackageNotFoundError:
__version__ = "version-unknown"
Loading

0 comments on commit 878a29f

Please sign in to comment.