Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge development into main: v5.0.1 #201

Merged
merged 39 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cd7fd28
update CHANGELOG.md for 5.0.0
zcutlip May 24, 2024
c3e7bd8
bump version to 5.0.1.dev0
zcutlip May 25, 2024
6b62a73
fix case of "testing and linting" workflow
zcutlip May 25, 2024
8e396ca
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] May 27, 2024
49b188c
Merge pull request #196 from zcutlip/pre-commit-ci-update-config
zcutlip May 29, 2024
61986c2
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jun 24, 2024
b320c49
Merge pull request #197 from zcutlip/pre-commit-ci-update-config
zcutlip Jun 25, 2024
c3919e9
remove relative import from example-create-item.py
zcutlip Jun 13, 2024
c271560
add serialize() method to OPNewItemMixin
zcutlip Jun 13, 2024
95edefd
remove secure_tempfile() method from OPNewItemMixin
zcutlip Jun 13, 2024
ca3a3b2
remove _copy_template() method from OPNewItemMixin
zcutlip Jun 13, 2024
656f4e5
remove __del__() method from OPNewItemMixin
zcutlip Jun 13, 2024
ba695f5
add 'encoding=' to _OPArgv.item_generic_argv()
zcutlip Jun 13, 2024
53c2376
refactor _OPArgv.item_create_argv() to not require item object or se…
zcutlip Jun 13, 2024
c7ad100
type hint item object in _OPCommandInterface.item_create()
zcutlip Jun 13, 2024
a3aa7db
refactor _OPCommandInterface._item_create() to pass item JSON over stdin
zcutlip Jun 14, 2024
2dd538d
remove tests involving OPNewItemMixin.secure_tempfile()
zcutlip Jun 14, 2024
cbaa5ed
remove instance variable tracking tempfiles when creating new item
zcutlip Jun 14, 2024
90ac97f
remove "nopep8" directive
zcutlip Jul 12, 2024
54d6393
remove remaining "nopep8" directives
zcutlip Jul 12, 2024
fbe971a
suppress mypy error for incompatible overridden method signature
zcutlip Jul 26, 2024
751b951
print some status from docker testing scripts
zcutlip Jul 26, 2024
2bf323c
fix typos in README
zcutlip Aug 4, 2024
9a41b2a
fix typo in comment in setup.py
zcutlip Aug 4, 2024
e1f137c
OPNewSecureNoteItem kwargs default to None
zcutlip Aug 4, 2024
c72d368
Revert "fix typos in README"
zcutlip Aug 4, 2024
eb3f470
fix typos in README template
zcutlip Aug 4, 2024
f43edea
add print statements to update_readme.py
zcutlip Aug 4, 2024
88c1dc2
regenerated README to fix typos
zcutlip Aug 4, 2024
14d3ea0
Merge pull request #198 from zcutlip/dev/172-create-new-items-via-std…
zcutlip Aug 4, 2024
09a8ce4
fix update_readmy.py print statement
zcutlip Aug 4, 2024
0ead342
bump version to 5.0.1
zcutlip Aug 4, 2024
bac4f58
regenerate README to reflect updated op CLI version support
zcutlip Aug 6, 2024
982e933
op version support
zcutlip Aug 6, 2024
b838341
update CHANGELOG.md for 5.0.1
zcutlip Aug 6, 2024
f5b0104
op version support
zcutlip Aug 6, 2024
8ff2f8e
regenerate README to reflect updated op CLI version support
zcutlip Aug 6, 2024
dcc9284
minor edits to CHANGELOG
zcutlip Aug 6, 2024
eef13bc
update CHANGELOG with references to gh-200
zcutlip Aug 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/testing-linting.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: testing and linting
name: Testing and Linting

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ repos:
- id: check-yaml
- id: check-merge-conflict
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.0
hooks:
- id: flake8
- repo: https://github.com/hhatto/autopep8
rev: 'v2.1.0'
rev: 'v2.3.1'
hooks:
- id: autopep8
- repo: https://github.com/pycqa/isort
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@

All notable changes to this project will be documented in this file.

## [5.0.1] 2024-08-03

### Fixed

- Create new items via stdin to `op` command rather than reading from temp file (gh-172)

### `op` CLI Version Support

*Deprecated support*

- `op` versions < 2.26.0 and >= 2.21.0 (gh-200)

*Unsupported*

- `op` versions < 2.21.0 (gh-200)


## [5.0.0] 2024-05-24

### Added

- Version checking for the `op` CLI tool at run-time
- Version checking for the `op` CLI tool at run-time (gh-162)
- `opversion` command
- Export `OPCLIVersion` as API
- `OPCLIVersionSupportException` class
Expand All @@ -21,7 +38,7 @@ All notable changes to this project will be documented in this file.

### Misc

- Remove `op` version checks for special behaviors where the version is no longer supported
- Remove `op` version checks for special behaviors where the version is no longer supported (gh-193)

## [4.3.0] 2024-03-28

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ A Python API to sign into and query a 1Password account using the `op` command.
## Requirements

- Python >= 3.9
- 1Password command-line tool >= 2.24.0
- Versions >= 2.19.0, < 2.24.0 supported but deprecated
- Versions < 2.19.0 are unsupported and an exception will be raised
- 1Password command-line tool >= 2.26.0
- Versions >= 2.21.0, < 2.26.0 supported but deprecated
- Versions < 2.21.0 are unsupported and an exception will be raised
- See [1Password Developer Documentation](https://developer.1password.com/docs/cli)
- Internet connectivity to 1Password.com
- The `op` command queries your online account, not your local vault
Expand Down Expand Up @@ -354,14 +354,14 @@ def main():

For details on creating new items in a 1Password vault, see [item-creation.md](docs/item-creation.md)

Also see the examles in [examples/item_creation](examples/item_creation/)
Also see the examples in [examples/item_creation](examples/item_creation/)


### Item Editing

For details on editing existing items in a 1Password vault, see [item-editing.md](docs/item-editing.md)

Also see the examles in [examples/item_editing](examples/item_editing/)
Also see the examples in [examples/item_editing](examples/item_editing/)

### Document Editing

Expand Down
4 changes: 2 additions & 2 deletions _readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ def main():

For details on creating new items in a 1Password vault, see [item-creation.md](docs/item-creation.md)

Also see the examles in [examples/item_creation](examples/item_creation/)
Also see the examples in [examples/item_creation](examples/item_creation/)


### Item Editing

For details on editing existing items in a 1Password vault, see [item-editing.md](docs/item-editing.md)

Also see the examles in [examples/item_editing](examples/item_editing/)
Also see the examples in [examples/item_editing](examples/item_editing/)

### Document Editing

Expand Down
5 changes: 5 additions & 0 deletions docker_testing/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

echo "Building..."

docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py39.Dockerfile -t docker_py39 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py310.Dockerfile -t docker_py310 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py311.Dockerfile -t docker_py311 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py312.Dockerfile -t docker_py312 || exit

echo "...done"
echo ""
5 changes: 5 additions & 0 deletions docker_testing/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

# keep unused docker image names so we can ensure they get removed
# this should not be an error
echo "Cleaning..."
echo "removing docker images"
docker image rm docker_py38 docker_py39 docker_py310 docker_py311 docker_py312
echo "removing .tox-docker"
rm -rf .tox-docker
echo "...done"
echo ""
3 changes: 3 additions & 0 deletions docker_testing/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ trap handle_sig INT

ret=0

echo "Running docker tests..."
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py39 /test.sh "$@"
ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py310 /test.sh "$@"
Expand All @@ -31,4 +32,6 @@ ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py312 /test.sh "$@"
ret="$(($?+ret))"

echo "...done"
echo ""
exit "$ret"
8 changes: 3 additions & 5 deletions examples/item_creation/example-create-item.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pyonepassword import OP
from pyonepassword import OP, logging
from pyonepassword.api.object_types import OPLoginItem

from ..do_signin import do_signin

if __name__ == "__main__":
# see README.md for sign-in process
op: OP = do_signin()

logger = logging.console_debug_logger("example-create-item")
op: OP = OP(logger=logger)
title = "Example Login Item"
username = "test_username"
great_password = "really-great-password"
Expand Down
6 changes: 3 additions & 3 deletions ipython_snippets/item_creation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional

from pyonepassword import OP # noqa: F401
from pyonepassword.api.object_types import (
Expand All @@ -23,8 +23,8 @@ class OPNewSecureNoteItem(OPNewItemMixin, OPSecureNoteItem):
def __init__(self,
title: str,
note_text: str,
fields: List[OPItemField] = [],
sections: List[OPSection] = []):
fields: Optional[List[OPItemField]] = None,
sections: Optional[List[OPSection]] = None):

if sections is None: # pragma: no coverage
sections = []
Expand Down
2 changes: 1 addition & 1 deletion pyonepassword/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "pyonepassword"
__version__ = "5.0.0"
__version__ = "5.0.1"
__summary__ = "A python API to query a 1Password account using the 'op' command-line tool"

"""
Expand Down
16 changes: 6 additions & 10 deletions pyonepassword/_op_cli_argv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from ._field_assignment import FIELD_TYPE_MAP, OPFieldTypeEnum
from ._svc_account import OPSvcAcctSupportCode, OPSvcAcctSupportRegistry
from .op_items._new_item import OPNewItemMixin
from .op_items.password_recipe import OPPasswordRecipe
from .string import RedactedString

Expand Down Expand Up @@ -127,7 +126,8 @@ def document_delete_argv(cls,
def item_generic_argv(cls,
op_exe: str,
subcommands: Optional[Union[str, List[str]]],
sub_cmd_args: Optional[List[str]] = None):
sub_cmd_args: Optional[List[str]] = None,
encoding="utf-8"):
args = []
global_args = ["--format", "json"]
if sub_cmd_args:
Expand All @@ -136,7 +136,8 @@ def item_generic_argv(cls,
"item",
args,
subcommands=subcommands,
global_args=global_args)
global_args=global_args,
encoding=encoding)
return argv

@classmethod
Expand Down Expand Up @@ -374,25 +375,20 @@ def account_forget_argv(cls, op_exe, account): # pragma: no coverage
@classmethod
def item_create_argv(cls,
op_exe,
item: OPNewItemMixin,
password_recipe: Optional[OPPasswordRecipe] = None,
vault: Optional[str] = None,
encoding="utf-8"):
"""
op item create --template ./new_item.json --vault "Test Data" --generate-password=20,letters,digits --dry-run --format json
"""
template_filename = item.secure_tempfile(
encoding=encoding)

item_create_args = ["--template", template_filename]

item_create_args = []
if password_recipe:
# '--password-recipe' requires an '=' unlike other option/argument pairs
item_create_args.append(f"--generate-password={password_recipe}")
if vault:
item_create_args.extend(["--vault", vault])
argv = cls.item_generic_argv(
op_exe, "create", sub_cmd_args=item_create_args)
op_exe, "create", sub_cmd_args=item_create_args, encoding=encoding)
return argv

@classmethod
Expand Down
14 changes: 8 additions & 6 deletions pyonepassword/_op_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OPSvcAcctCommandNotSupportedException
)
from .account import OPAccount, OPAccountList
from .op_items._new_item import OPNewItemMixin
from .op_items.password_recipe import OPPasswordRecipe
from .py_op_exceptions import (
OPAuthenticationException,
Expand Down Expand Up @@ -131,7 +132,7 @@ def __init__(self,
# if a password is passed in but existing_auth is required, caller may be confused:
# - intentionally passed in incompatible options
# - possibly has OP_SERVICE_ACCOUNT_TOKEN set accidentally
msg = f"Password argument passed but EXISTING_AUTH_REQD flag is set. flag source: {auth_pref_source}" # nopep8
msg = f"Password argument passed but EXISTING_AUTH_REQD flag is set. flag source: {auth_pref_source}"
self.logger.error(msg)
raise OPAuthenticationException(msg)

Expand Down Expand Up @@ -796,11 +797,12 @@ def _item_list(self, categories=[], include_archive=False, tags=[], vault=None,
raise OPItemListException.from_opexception(e)
return output

def _item_create(self, item, vault, password_recipe, decode="utf-8"):
argv = self._item_create_argv(item, password_recipe, vault)
def _item_create(self, item: OPNewItemMixin, vault, password_recipe, decode="utf-8"):
item_json = item.serialize(indent=2)
argv = self._item_create_argv(password_recipe, vault)
try:
output = self._run_with_auth_check(
self.op_path, self._account_identifier, argv, capture_stdout=True, decode=decode)
self.op_path, self._account_identifier, argv, capture_stdout=True, input=item_json, decode=decode)
except OPCmdFailedException as e:
raise OPItemCreateException.from_opexception(e)

Expand Down Expand Up @@ -984,10 +986,10 @@ def _vault_list_argv(self, group_name_or_id=None, user_name_or_id=None):
self.op_path, group_name_or_id=group_name_or_id, user_name_or_id=user_name_or_id)
return vault_list_argv

def _item_create_argv(self, item, password_recipe, vault):
def _item_create_argv(self, password_recipe, vault):
vault_arg = vault if vault else self.vault
item_create_argv = _OPArgv.item_create_argv(
self.op_path, item, password_recipe=password_recipe, vault=vault_arg
self.op_path, password_recipe=password_recipe, vault=vault_arg
)
return item_create_argv

Expand Down
4 changes: 2 additions & 2 deletions pyonepassword/_py_op_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def _rename_kwargs(func_name: str, kwargs: Dict[str, Any], kwarg_aliases: Dict[s
if old_kwarg in kwargs:
if new_kwarg in kwargs:
raise TypeError(
f"{func_name} received both {old_kwarg} and {new_kwarg} as arguments!" # nopep8
f"{func_name} received both {old_kwarg} and {new_kwarg} as arguments!"
f" {old_kwarg} is deprecated, use {new_kwarg} instead."
)
warnings.warn(
message=(
f"`{old_kwarg}` is deprecated as an argument to `{func_name}`; use" # nopep8
f"`{old_kwarg}` is deprecated as an argument to `{func_name}`; use"
f" `{new_kwarg}` instead."
),
category=DeprecationWarning,
Expand Down
6 changes: 3 additions & 3 deletions pyonepassword/_svc_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def command_supported(self, _argv: List[str]) -> OPSvcAcctSupportCode:
# then command is not supported
_cmd_not_found = command is not None and cmd_spec is None
if (cmd_spec and not cmd_dict) or _cmd_not_found:
_support_msg = f"Command or subcommand not supported: [{command} {' '.join(subcommands)}]" # nopep8
_support_msg = f"Command or subcommand not supported: [{command} {' '.join(subcommands)}]"
_support_code = SVC_ACCT_CMD_NOT_SUPPORTED

if cmd_dict and _support_code == _SVC_ACCT_CMD_NOT_VALIDATED:
Expand Down Expand Up @@ -220,10 +220,10 @@ def command_supported(self, _argv: List[str]) -> OPSvcAcctSupportCode:
if _support_code == SVC_ACCT_INCOMPAT_OPTIONS:
_support_msg = ""
if not required_opt_satified:
_support_msg += f"Required options not provided: [{','.join(list(reqd_opt_diff))}]" # nopep8
_support_msg += f"Required options not provided: [{','.join(list(reqd_opt_diff))}]"

if not prohibited_opt_satisfied:
_support_msg += f" Prohibited options found: [{','.join(list(prohib_opt_diff))}]" # nopep8
_support_msg += f" Prohibited options found: [{','.join(list(prohib_opt_diff))}]"

_support_msg = _support_msg.lstrip()

Expand Down
4 changes: 2 additions & 2 deletions pyonepassword/data/op_versions/version_support.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": 1
},
"version-support":{
"supported": "2.24.0",
"minimum": "2.19.0"
"supported": "2.26.0",
"minimum": "2.21.0"
},
"feature-support": {
"example-feature-service-accounts": "2.18.0"
Expand Down
2 changes: 1 addition & 1 deletion pyonepassword/op_items/_item_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def serialize(self, indent=None) -> str:
json_str = json.dumps(self, indent=indent)
return json_str

def sort(self):
def sort(self): # type: ignore[override]
# we really want to be sorted by title, since that's the most
# human friendly (mainly for troubleshooting)
# but in the case if title collisions, this is still non-deterministic
Expand Down
Loading