Skip to content

Commit

Permalink
Merge branch 'config' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Sep 11, 2021
2 parents 572731c + 8ae66af commit 83c0623
Show file tree
Hide file tree
Showing 46 changed files with 272 additions and 301 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1.1.8
- uses: snok/install-poetry@v1.2
with:
version: 1.2.0a2
virtualenvs-in-project: true
Expand Down Expand Up @@ -69,20 +69,3 @@ jobs:
python-version: ${{ env.LATEST_PY_VERSION }}
- name: Run style checks & linting
uses: pre-commit/action@v2.0.3

# TODO: This section could be removed if the issues with the mypy pre-commit hook were resolved
- uses: snok/install-poetry@v1.1.8
with:
version: 1.2.0a2
virtualenvs-in-project: true
- name: Cache python packages
id: cache
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ matrix.python-version }}-latest-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v -E all
- name: Run type checking
run: poetry run mypy --install-types --non-interactive
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ repos:
hooks:
- id: xenon
args: [--max-average=A, --max-modules=C, --max-absolute=C]
# TODO: This is currently failing for attrs classes in CI, but passes locally.
# Mypy run without pre-commit also passes.
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.910
# hooks:
# - id: mypy
# entry: bash -c 'mypy "$@" || true' --
# additional_dependencies: [types-python-dateutil, types-requests]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
additional_dependencies: [attrs, types-python-dateutil, types-requests]
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## 0.15.1 (2021-TBD)
* Remove `pyinaturalist.user_agent` global variable and API function keyword args, and recommend
setting on session object instead

## 0.15.0 (2021-09-07)

### New Endpoints
Expand Down
2 changes: 2 additions & 0 deletions docs/automodapi.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

.. This file exists only to generate sources.
.. Then automodsumm is used to generate a table of classes only.
.. automodapi:: pyinaturalist.models
Expand Down
9 changes: 8 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@
# apidoc settings
apidoc_module_dir = PACKAGE_DIR
apidoc_output_dir = MODULE_DOCS_DIR
apidoc_excluded_paths = ['controllers/*', 'docs/*', 'models/*', 'node_api.py', 'rest_api.py']
apidoc_excluded_paths = [
'controllers/*',
'docs/*',
'models/*',
'constants.py',
'node_api.py',
'rest_api.py',
]
apidoc_extra_args = [f'--templatedir={TEMPLATE_DIR}'] # Note: Must be an absolute path
apidoc_module_first = True
apidoc_separate_modules = True
Expand Down
29 changes: 5 additions & 24 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,6 @@ $Env:DRY_RUN_ENABLED="true"
```
:::

You can also set this as a global variable:

:::{warning}
This usage is deprecated and will be removed in a future release.
```python
>>> import pyinaturalist
>>> pyinaturalist.DRY_RUN_ENABLED = True
```
:::

### Dry-run only write requests
If you would like to send real `GET` requests but mock out any requests that modify data
Expand Down Expand Up @@ -479,25 +470,15 @@ $Env:DRY_RUN_WRITE_ONLY="true"
:::

## User Agent
While not mandatory, it's good practice to include a [user-agent](https://en.wikipedia.org/wiki/User_agent) in
your API calls. This field can be either something that identifies the project or its contact person.
If you're using the API as part of a project or application, it's good practice to add that info to
the [user-agent](https://en.wikipedia.org/wiki/User_agent). You can optionally set this on the
session object used to make requests:

You can set this globally:
```python
>>> import pyinaturalist
>>>
>>> pyinaturalist.user_agent = "MyCoolAndroidApp/2.0 (using Pyinaturalist)"
>>> # From now on, all API calls will use this user-agent.
>>> from pyinaturalist import ClientSession
>>> session = ClientSession(user_agent='my_app/1.0.0')
```

Or to set this for individual requests, all API functions accept an optional `user_agent` parameter:
```python
>>> from pyinaturalist import get_observation
>>> get_observation(observation_id=16227955, user_agent='Jane Doe \<jane.doe@gmail.com>')
```

If not configured, `Pyinaturalist/<VERSION>` will be used.

## API Recommended Practices
See [API Recommended Practices](https://www.inaturalist.org/pages/api+recommended+practices)
on iNaturalist for more general usage information and notes.
14 changes: 9 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
LIVE_DOCS_PORT = 8181
LIVE_DOCS_IGNORE = ['*.csv', '*.ipynb', '*.pyc', '*.tmp', '**/modules/*']
LIVE_DOCS_WATCH = ['pyinaturalist', 'examples']
CLEAN_DIRS = ['dist', 'build', join('docs', '_build'), join('docs', 'models'), join('docs', 'modules')]
CLEAN_DIRS = [
'dist',
'build',
join('docs', '_build'),
join('docs', 'models'),
join('docs', 'modules'),
]


@session(python=['3.6', '3.7', '3.8', '3.9', '3.10'])
Expand Down Expand Up @@ -69,7 +75,5 @@ def livedocs(session):
@session(python=False)
def lint(session):
"""Run linters and code formatters via pre-commit"""
cmd_1 = 'pre-commit run --all-files'
cmd_2 = 'mypy --install-types --non-interactive'
session.run(*cmd_1.split(' '))
session.run(*cmd_2.split(' '))
cmd = 'pre-commit run --all-files'
session.run(*cmd.split(' '))
Loading

0 comments on commit 83c0623

Please sign in to comment.