Skip to content

Commit

Permalink
Merge pull request #10 from RazerM/feature/modern-packaging
Browse files Browse the repository at this point in the history
Modern packaging
  • Loading branch information
RazerM authored Dec 30, 2023
2 parents 5e06ad4 + c5840b7 commit a8a2467
Show file tree
Hide file tree
Showing 38 changed files with 1,463 additions and 1,551 deletions.
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.1.0
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.11"

python:
install:
- method: pip
path: .
extra_requirements:
- docs
75 changes: 0 additions & 75 deletions .travis.yml

This file was deleted.

24 changes: 22 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# Change Log

## [Unreleased][unreleased]
N/A

### Changed

- Python 3.7 or later is required.

### Removed

- `pg_grant.__version__`, use `importlib.metadata` instead.
- `pg_grant.__description__`, use `importlib.metadata` instead.
- `pg_grant.__license__`, use `importlib.metadata` instead.
- `pg_grant.__author__`, use `importlib.metadata` instead.
- `pg_grant.__email__`, use `importlib.metadata` instead.

## [0.4.0][]

**This release supports SQLAlchemy 1.4 and 2.0. The next release will require
SQLAlchemy 2.0 or later**

## Changed

- Python 3.6 or later is required.

## [0.3.3][]
Expand All @@ -17,26 +29,34 @@ SQLAlchemy 2.0 or later**
SQLAlchemy 1.4 or later**

### Fixed

- ACLs for functions without any arguments (i.e. `arg_types=()`) could not be
queried using `get_function_acl`.
queried using `get_function_acl`.

## [0.3.2][] - 2020-05-21

### Fixed

- Type annotations for `parse_acl` and `parse_acl_item`.

## [0.3.1][] - 2018-01-17

### Fixed

- `pg_grant` can be installed with setuptools v38.0+, which requires
`install_requires` in `setup.py` to be ordered.

## [0.3.0][] - 2017-10-31

### Added

- `parse_acl` function to call `parse_acl_item` on each item in a list.
- Documentation on `parse_acl_item` about ensuring `subname` is a valid
identifier if it is to be executed.
- `get_all_column_acls` and `get_column_acls` to get column ACLs.

### Changed

- Renamed singular functions like `get_table_acls` to `get_table_acl`.
- `get_all_table_acls` and `get_table_acl` also return views, materialized
views, partitioned tables (PostgreSQL 10+), and foreign tables.
Expand Down
12 changes: 7 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ Without the SQLAlchemy extra, ``pg_grant`` can only parse access privileges.
Example
~~~~~~~

.. code:: python
.. code:: pycon
>>> from pg_grant import parse_acl_item
>>> parse_acl_item('bob=arw*/alice')
>>> parse_acl_item("bob=arw*/alice")
Privileges(grantee='bob', grantor='alice', privs=['SELECT', 'INSERT'], privswgo=['UPDATE'])
>>> from sqlalchemy import create_engine
>>> from pg_grant.query import get_table_acl
>>> engine = create_engine('postgresql://...')
>>> get_table_acl(engine, 'table2')
>>> engine = create_engine("postgresql://...")
>>> with engine.connect() as conn:
... get_table_acl(conn, "table2")
...
SchemaRelationInfo(oid=138067, name='table2', owner='alice', acl=['alice=arwdDxt/alice', 'bob=arwdDxt/alice'], schema='public')
>>> from pg_grant import PgObjectType
>>> from pg_grant.sql import revoke
>>> stmt = revoke(['SELECT'], PgObjectType.TABLE, 'table2', 'bob')
>>> stmt = revoke(["SELECT"], PgObjectType.TABLE, "table2", "bob")
>>> str(stmt)
'REVOKE SELECT ON TABLE table2 FROM bob'
>>> engine.execute(stmt)
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-e .[sqlalchemy,test]
bumpversion
invoke
twine
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: '3'
version: "3"
services:
postgres:
image: postgres:14
ports:
- '127.0.0.1:5440:5432'
- "127.0.0.1:5440:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
Expand Down
Loading

0 comments on commit a8a2467

Please sign in to comment.