Skip to content

Commit

Permalink
Drop support for Python 3.7 (end-of-life)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger committed Jun 28, 2023
1 parent 4c8c7e0 commit 79e3bb9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python-version: ["3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- python-version: "3.7"
- python-version: "3.8"
os: ubuntu-latest
runs-on: ${{ matrix.os }}
defaults:
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

## unreleased
## 2023.1.0 (unreleased)

- Better handling of server response errors.
- Drop support for Python 3.7. `openneuro-py` now requires Python 3.8 or newer.

## 2022.2.0

Expand Down
6 changes: 1 addition & 5 deletions openneuro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from importlib import metadata
except ImportError:
# Running on pre-3.8 Python; use importlib-metadata package
import importlib_metadata as metadata
from importlib import metadata

try:
__version__ = metadata.version("openneuro-py")
Expand Down
5 changes: 1 addition & 4 deletions openneuro/_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import string
import json
from typing import Optional, Union
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing import Literal

if sys.version_info >= (3, 9):
from collections.abc import Iterable, Generator
Expand Down
44 changes: 22 additions & 22 deletions openneuro/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
import stat
import json
import getpass
if sys.version_info >= (3, 8):
from typing import TypedDict
else:
from typing_extensions import TypedDict
from typing import TypedDict

import appdirs
from tqdm.auto import tqdm


CONFIG_DIR = Path(
appdirs.user_config_dir(appname='openneuro-py', appauthor=False, roaming=True)
appdirs.user_config_dir(appname="openneuro-py", appauthor=False, roaming=True)
)
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
CONFIG_PATH = CONFIG_DIR / 'config.json'
BASE_URL = 'https://openneuro.org/'
CONFIG_PATH = CONFIG_DIR / "config.json"
BASE_URL = "https://openneuro.org/"


class Config(TypedDict):
Expand All @@ -27,18 +24,19 @@ class Config(TypedDict):


def init_config() -> None:
"""Initialize a new OpenNeuro configuration file.
"""
tqdm.write('🙏 Please login to your OpenNeuro account and go to: '
'My Account → Obtain an API Key')
api_key = getpass.getpass('OpenNeuro API key (input hidden): ')
"""Initialize a new OpenNeuro configuration file."""
tqdm.write(
"🙏 Please login to your OpenNeuro account and go to: "
"My Account → Obtain an API Key"
)
api_key = getpass.getpass("OpenNeuro API key (input hidden): ")

config: Config = {
'endpoint': BASE_URL,
'apikey': api_key,
"endpoint": BASE_URL,
"apikey": api_key,
}

with open(CONFIG_PATH, 'w', encoding='utf-8') as f:
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(config, f, indent=2)
os.chmod(CONFIG_PATH, stat.S_IRUSR | stat.S_IWUSR)

Expand All @@ -51,7 +49,7 @@ def load_config() -> dict:
dict
The configuration options.
"""
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
config = json.load(f)
return config

Expand All @@ -70,12 +68,14 @@ def get_token() -> str:
"""
if not CONFIG_PATH.exists():
raise ValueError(
'Could not read API token as no openneuro-py configuration '
"Could not read API token as no openneuro-py configuration "
'file exists. Run "openneuro login" to generate it.'
)
config = load_config()
if 'apikey' not in config:
raise ValueError('An openneuro-py configuration file was found, but did not '
'contain an "apikey" entry. Run "openneuro login" to '
'add such an entry.')
return config['apikey']
if "apikey" not in config:
raise ValueError(
"An openneuro-py configuration file was found, but did not "
'contain an "apikey" entry. Run "openneuro login" to '
"add such an entry."
)
return config["apikey"]
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "openneuro-py"
description = "A Python client for OpenNeuro."
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
license = {file = "LICENSE"}
keywords = ["science", "neuroscience"]
authors = [
Expand All @@ -19,8 +19,6 @@ dependencies = [
"click",
"aiofiles",
"sgqlc",
"importlib-metadata; python_version < '3.8'",
"typing-extensions; python_version < '3.8'",
"appdirs",
]
dynamic = ["version"]
Expand Down

0 comments on commit 79e3bb9

Please sign in to comment.