Skip to content

Commit

Permalink
replace black with ruff, other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yehoshuadimarsky committed Nov 20, 2024
1 parent d09c72e commit 610cd84
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 42 deletions.
6 changes: 2 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ repos:
rev: 'v0.7.3'
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rules:
max: 130
truthy:
check-keys: false
new-lines: disable
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knowledge of BCP required!! (pronounced _BEE-CEE-Pandas_)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Quickstart](#quickstart)
- [IMPORTANT - Read vs. Write](#important---read-vs-write)
- [Benchmarks](#benchmarks)
Expand Down
1 change: 1 addition & 0 deletions TODO.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Completed](#completed)
- [Open](#open)
- [General](#general)
Expand Down
8 changes: 2 additions & 6 deletions bcpandas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ def _sql_item_exists(sql_type: str, schema: str, table_name: str, creds: SqlCred
FROM INFORMATION_SCHEMA.{_typ}S
WHERE TABLE_SCHEMA = '{_schema}'
AND TABLE_NAME = '{_tbl}'
""".format(
_typ=sql_type.upper(), _schema=schema, _tbl=table_name
)
""".format(_typ=sql_type.upper(), _schema=schema, _tbl=table_name)
)
res = pd.read_sql_query(sql=_qry, con=creds.engine)
return res.shape[0] > 0
Expand Down Expand Up @@ -247,9 +245,7 @@ def _handle_cols_for_append(
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = '{_schema}'
AND TABLE_NAME = '{_tbl}'
""".format(
_schema=schema, _tbl=table_name
)
""".format(_schema=schema, _tbl=table_name)
),
creds.engine,
).values
Expand Down
35 changes: 6 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,44 +50,21 @@ requests = "*"
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]

# Example configuration for Black.

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.

[tool.black]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
include = '\.pyi?$'
line-length = 99
target-version = ["py38"]

[tool.ruff]
exclude = ["build"]
ignore = ["E501"]
line-length = 99

target-version = "py38"

[tool.ruff.lint]
select = [
"E",
"F",
"W",
]
target-version = "py38"

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
force-sort-within-sections = true
force-wrap-aliases = true
Expand All @@ -99,7 +76,7 @@ keep-runtime-typing = true
[tool.mypy]
ignore_missing_imports = true
pretty = true
python_version = 3.8
python_version = "3.8"
show_error_codes = true

[tool.pytest.ini_options]
Expand Down
4 changes: 1 addition & 3 deletions tests/test_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ def test_tosql_empty_df(df, sql_creds):
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '{_schema}'
AND TABLE_NAME = '{_tbl}'
""".format(
_tbl=tbl_name, _schema=schema_name
)
""".format(_tbl=tbl_name, _schema=schema_name)
res = pd.read_sql_query(sql=qry, con=sql_creds.engine)
# assert that rows == 0, it has columns even without rows because it is an internal system table
assert res.shape[0] == 0
Expand Down

0 comments on commit 610cd84

Please sign in to comment.