Skip to content

Commit

Permalink
Fix doc, lint CI dependency issues (#251)
Browse files Browse the repository at this point in the history
* infra: fix CI lint, doc jobs

* Update CHANGES.rst

* chore: lint

* chore: lint
  • Loading branch information
Brooke-white committed May 11, 2022
1 parent 065833c commit aa95baf
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
(`Pull #246 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/246>`_)
- Disable supports_statement_cache
(`Pull #249 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/249>`_)
- Fix doc, lint CI dependency issues
(`Pull #250 <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/pull/250>`_)

0.8.9 (2021-12-15)
------------------
Expand Down
1 change: 1 addition & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
sphinx==1.5.3
numpydoc==0.6.0
psycopg2-binary==2.9.1
jinja2<3.1.0
2 changes: 1 addition & 1 deletion sqlalchemy_redshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

__version__ = get_distribution('sqlalchemy-redshift').version

from sqlalchemy.dialects import registry
from sqlalchemy.dialects import registry # noqa

registry.register(
"redshift", "sqlalchemy_redshift.dialect",
Expand Down
4 changes: 2 additions & 2 deletions sqlalchemy_redshift/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
TOKEN_RE = re.compile('[A-Za-z0-9/+=]+')
AWS_PARTITIONS = frozenset({'aws', 'aws-cn', 'aws-us-gov'})
AWS_ACCOUNT_ID_RE = re.compile('[0-9]{12}')
IAM_ROLE_NAME_RE = re.compile('[A-Za-z0-9+=,.@\-_]{1,64}')
IAM_ROLE_NAME_RE = re.compile('[A-Za-z0-9+=,.@\-_]{1,64}') # noqa
IAM_ROLE_ARN_RE = re.compile('arn:(aws|aws-cn|aws-us-gov):iam::'
'[0-9]{12}:role/[A-Za-z0-9+=,.@\-_]{1,64}')
'[0-9]{12}:role/[A-Za-z0-9+=,.@\-_]{1,64}') # noqa


def _process_aws_credentials(access_key_id=None, secret_access_key=None,
Expand Down
24 changes: 15 additions & 9 deletions sqlalchemy_redshift/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ class RedshiftTypeEngine(TypeEngine):

def _default_dialect(self, default=None):
"""
Returns the default dialect used for TypeEngine compilation yielding String result.
Returns the default dialect used for TypeEngine compilation yielding
String result.
:meth:`~sqlalchemy.sql.type_api.TypeEngine.compile`
"""
Expand All @@ -208,9 +209,9 @@ class TIMESTAMPTZ(RedshiftTypeEngine, sa.dialects.postgresql.TIMESTAMP):
__visit_name__ = 'TIMESTAMPTZ'

def __init__(self, timezone=True, precision=None):
# timezone param must be present as it's provided in base class so the object
# can be instantiated with kwargs
# see :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
# timezone param must be present as it's provided in base class so the
# object can be instantiated with kwargs. see
# :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
super(TIMESTAMPTZ, self).__init__(timezone=True, precision=precision)


Expand All @@ -229,9 +230,9 @@ class TIMETZ(RedshiftTypeEngine, sa.dialects.postgresql.TIME):
__visit_name__ = 'TIMETZ'

def __init__(self, timezone=True, precision=None):
# timezone param must be present as it's provided in base class so the object
# can be instantiated with kwargs
# see :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
# timezone param must be present as it's provided in base class so the
# object can be instantiated with kwargs. see
# :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
super(TIMETZ, self).__init__(timezone=True, precision=precision)


Expand Down Expand Up @@ -281,6 +282,7 @@ def process_bind_param(self, value, dialect):
return json.dumps(value)
return value


class HLLSKETCH(RedshiftTypeEngine, sa.dialects.postgresql.TEXT):
"""
Redshift defines a HLLSKETCH column type
Expand All @@ -299,6 +301,7 @@ def __init__(self):
def get_dbapi_type(self, dbapi):
return dbapi.HLLSKETCH


# Mapping for database schema inspection of Amazon Redshift datatypes
REDSHIFT_ISCHEMA_NAMES = {
"geometry": GEOMETRY,
Expand Down Expand Up @@ -556,7 +559,7 @@ class RedshiftDialectMixin(DefaultDialect):
name = 'redshift'
max_identifier_length = 127
# explicitly disables statement cache to disable warnings in logs
# ref: https://docs.sqlalchemy.org/en/14/core/connections.html#caching-for-third-party-dialects
# ref: https://docs.sqlalchemy.org/en/14/core/connections.html#caching-for-third-party-dialects # noqa
supports_statement_cache = False

statement_compiler = RedshiftCompiler
Expand Down Expand Up @@ -598,7 +601,10 @@ def ischema_names(self):
Used in
:meth:`~sqlalchemy.engine.dialects.postgresql.base.PGDialect._get_column_info`.
"""
return {**super(RedshiftDialectMixin, self).ischema_names, **REDSHIFT_ISCHEMA_NAMES}
return {
**super(RedshiftDialectMixin, self).ischema_names,
**REDSHIFT_ISCHEMA_NAMES
}

@reflection.cache
def get_columns(self, connection, table_name, schema=None, **kw):
Expand Down
1 change: 1 addition & 0 deletions tests/test_dialect_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_defined_types():
assert sqlalchemy_redshift.dialect.HLLSKETCH \
is not sqlalchemy.sql.sqltypes.TEXT


custom_type_inheritance = [
(
sqlalchemy_redshift.dialect.GEOMETRY,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ deps =

[testenv:lint]
deps =
flake8==2.4.0
flake8==4.0.1
psycopg2
redshift_connector
commands=flake8 sqlalchemy_redshift tests
Expand Down

0 comments on commit aa95baf

Please sign in to comment.