diff --git a/pyproject.toml b/pyproject.toml index 64cdf3977fa..4801a5537f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -247,7 +247,6 @@ docstring-code-format = true [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "tests/**" = ["ANN201", "D", "PLR0124"] -"tasks.py" = ["D"] "src/pymatgen/analysis/*" = ["D"] "src/pymatgen/io/*" = ["D"] "dev_scripts/*" = ["D"] diff --git a/tasks.py b/tasks.py index 5beb63bcb6c..618034bee74 100644 --- a/tasks.py +++ b/tasks.py @@ -1,9 +1,10 @@ """ Pyinvoke tasks.py file for automating releases and admin stuff. -To cut a new pymatgen release, use `invoke update-changelog` followed by `invoke release`. +To cut a new pymatgen release: -Author: Shyue Ping Ong + invoke update-changelog + invoke release """ from __future__ import annotations @@ -88,6 +89,13 @@ def publish(ctx: Context) -> None: @task def set_ver(ctx: Context, version: str): + """ + Set version in pyproject.toml file. + + Args: + ctx (Context): The context. + version (str): An input version. + """ with open("pyproject.toml") as file: lines = [re.sub(r"^version = \"([^,]+)\"", f'version = "{version}"', line.rstrip()) for line in file] @@ -104,6 +112,7 @@ def release_github(ctx: Context, version: str) -> None: Release to Github using Github API. Args: + ctx (Context): The context. version (str): The version. """ with open("docs/CHANGES.md", encoding="utf-8") as file: @@ -129,36 +138,6 @@ def release_github(ctx: Context, version: str) -> None: print(response.text) -def post_discourse(version: str) -> None: - """ - Post release announcement to http://discuss.matsci.org/c/pymatgen. - - Args: - version (str): The version. - """ - with open("CHANGES.rst", encoding="utf-8") as file: - contents = file.read() - tokens = re.split(r"\-+", contents) - desc = tokens[1].strip() - tokens = desc.split("\n") - desc = "\n".join(tokens[:-1]).strip() - raw = f"v{version}\n\n{desc}" - payload = { - "topic_id": 36, - "raw": raw, - } - response = requests.post( - "https://discuss.matsci.org/c/pymatgen/posts.json", - data=payload, - params={ - "api_username": os.environ["DISCOURSE_API_USERNAME"], - "api_key": os.environ["DISCOURSE_API_KEY"], - }, - timeout=600, - ) - print(response.text) - - @task def update_changelog(ctx: Context, version: str | None = None, dry_run: bool = False) -> None: """Create a preliminary change log using the git logs. @@ -238,6 +217,9 @@ def release(ctx: Context, version: str | None = None, nodoc: bool = False) -> No def open_doc(ctx: Context) -> None: """ Open local documentation in web browser. + + Args: + ctx (invoke.Context): The context object. """ pth = os.path.abspath("docs/_build/html/index.html") webbrowser.open(f"file://{pth}")