Skip to content

Commit

Permalink
Merge pull request #269 from marksmayo/dev
Browse files Browse the repository at this point in the history
pylint fixes
  • Loading branch information
chfw committed Jul 16, 2023
2 parents ee0722a + 0f7dee8 commit f1bf5fe
Show file tree
Hide file tree
Showing 67 changed files with 190 additions and 243 deletions.
5 changes: 2 additions & 3 deletions examples/database/import_xls_into_database_via_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
"""
import os
import datetime

import pyexcel

from sqlalchemy import Date, Float, Column, String, Integer, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import pyexcel


engine = create_engine("sqlite:///birth.db")
Base = declarative_base()
Expand Down
2 changes: 1 addition & 1 deletion examples/memoryfile/pyexcel_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"""
import sys

from flask import Flask, jsonify, request, make_response, render_template
import pyexcel as pe

from flask import Flask, jsonify, request, make_response, render_template

app = Flask(__name__)

Expand Down
7 changes: 3 additions & 4 deletions pyexcel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
iget_records,
save_book_as,
get_book_dict,
isave_book_as,
isave_book_as
)
from .sheet import Sheet

# flake8: noqa
from .cookbook import (
split_a_book,
merge_all_to_a_book,
merge_csv_to_a_book,
extract_a_sheet_from_a_book,
extract_a_sheet_from_a_book
)
from .deprecated import (
Reader,
Expand All @@ -44,7 +43,7 @@
load_from_dict,
load_from_memory,
load_from_records,
load_book_from_memory,
load_book_from_memory
)
from .__version__ import __author__, __version__
from .internal.garbagecollector import free_resources
4 changes: 2 additions & 2 deletions pyexcel/_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys
import warnings
from io import BytesIO, StringIO
from urllib import request as request
from urllib import request
from textwrap import dedent
from itertools import zip_longest
from collections import OrderedDict
Expand Down Expand Up @@ -48,7 +48,7 @@ def is_string(atype):
"""find out if a type is str or not"""
if atype == str:
return True
elif PY2:
if PY2:
if atype == unicode:
return True
return False
Expand Down
14 changes: 6 additions & 8 deletions pyexcel/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def __getitem__(self, key):
"""Override operator[]"""
if isinstance(key, int):
return self.sheet_by_index(key)
else:
return self.sheet_by_name(key)
return self.sheet_by_name(key)

def __delitem__(self, other):
"""
Expand Down Expand Up @@ -220,12 +219,11 @@ def to_book(bookstream):
"""Convert a bookstream to Book"""
if isinstance(bookstream, Book):
return bookstream
else:
return Book(
bookstream.to_dict(),
filename=bookstream.filename,
path=bookstream.path,
)
return Book(
bookstream.to_dict(),
filename=bookstream.filename,
path=bookstream.path,
)


def local_uuid():
Expand Down
6 changes: 3 additions & 3 deletions pyexcel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
:license: New BSD License
"""
import re

from pyexcel import constants as constants
from pyexcel_io import manager
from pyexcel import constants
from pyexcel import docstrings as docs
from pyexcel.book import Book, to_book
from pyexcel.sheet import Sheet
from pyexcel._compact import OrderedDict, append_doc, zip_longest
from pyexcel.internal import core as sources

from pyexcel_io import manager as manager


STARTS_WITH_DEST = "^dest_(.*)"
SAVE_AS_EXCEPTION = (
Expand Down
29 changes: 13 additions & 16 deletions pyexcel/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def Reader(file_name=None, sheetname=None, **keywords):
sheet_name=sheetname,
**keywords
)
else:
return get_sheet(file_name=file_name, sheet_name=sheetname, **keywords)
return get_sheet(file_name=file_name, sheet_name=sheetname, **keywords)


@partial(
Expand All @@ -157,13 +156,12 @@ def SeriesReader(file_name=None, sheetname=None, series=0, **keywords):
name_columns_by_row=series,
**keywords
)
else:
return load(
file_name,
sheetname=sheetname,
name_columns_by_row=series,
**keywords
)
return load(
file_name,
sheetname=sheetname,
name_columns_by_row=series,
**keywords
)


@partial(
Expand All @@ -183,13 +181,12 @@ def ColumnSeriesReader(file_name=None, sheetname=None, series=0, **keywords):
name_rows_by_column=series,
**keywords
)
else:
return load(
file_name,
sheetname=sheetname,
name_rows_by_column=series,
**keywords
)
return load(
file_name,
sheetname=sheetname,
name_rows_by_column=series,
**keywords
)


@partial(
Expand Down
2 changes: 1 addition & 1 deletion pyexcel/docstrings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
IGET_RECORDS,
SAVE_BOOK_AS,
GET_BOOK_DICT,
ISAVE_BOOK_AS,
ISAVE_BOOK_AS
)
from .meta import SAVE_AS_OPTIONS
from .garbagecollector import FREE_RESOURCES
2 changes: 1 addition & 1 deletion pyexcel/internal/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:copyright: (c) 2015-2022 by Onni Software Ltd.
:license: New BSD License
"""
from pyexcel import constants as constants
from pyexcel import constants

ATTRIBUTE_REGISTRY = {
constants.SHEET: {
Expand Down
5 changes: 2 additions & 3 deletions pyexcel/internal/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NO_COLUMN_NAMES = "Only sheet with column names is accepted"


class SheetIterator(object):
class SheetIterator():
"""
Sheet Iterator
"""
Expand All @@ -30,8 +30,7 @@ def next(self):
if self.current < self.book_reader_ref.number_of_sheets():
self.current += 1
return self.book_reader_ref[self.current - 1]
else:
raise StopIteration
raise StopIteration


def get_sheet_headers(sheet):
Expand Down
3 changes: 1 addition & 2 deletions pyexcel/internal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def get_sheet_stream(**keywords):
if sheets:
sheet_name, data = _one_sheet_tuple(sheets.items())
return SheetStream(sheet_name, data)
else:
return SheetStream(DEFAULT_NO_DATA, [[]])
return SheetStream(DEFAULT_NO_DATA, [[]])


def get_book_stream(**keywords):
Expand Down
4 changes: 2 additions & 2 deletions pyexcel/internal/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pyexcel.internal.common import SheetIterator


class SheetStream(object):
class SheetStream():
"""
Memory efficient sheet representation
Expand Down Expand Up @@ -47,7 +47,7 @@ def get_internal_array(self):
return self.payload


class BookStream(object):
class BookStream():
"""
Memory efficient book representation
Expand Down
6 changes: 3 additions & 3 deletions pyexcel/internal/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
from functools import partial

from pyexcel import constants as constants
from pyexcel import constants
from pyexcel import docstrings as docs
from pyexcel._compact import PY2, append_doc
from pyexcel.internal import SOURCE
Expand Down Expand Up @@ -143,7 +143,7 @@ def attribute(
)


class StreamAttribute(object):
class StreamAttribute():
"""Provide access to get_*_stream methods"""

def __init__(self, cls):
Expand All @@ -154,7 +154,7 @@ def __getattr__(self, name):
return getter(file_type=name)


class PyexcelObject(object):
class PyexcelObject():
"""parent class for pyexcel.Sheet and pyexcel.Book"""

@property
Expand Down
11 changes: 4 additions & 7 deletions pyexcel/internal/sheets/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .formatters import to_format


class CommonPropertyAmongRowNColumn(object):
class CommonPropertyAmongRowNColumn():
"""
Group reusable functions from row and column
"""
Expand Down Expand Up @@ -59,7 +59,7 @@ def analyse_slice(aslice, upper_bound):
stop = min(aslice.stop, upper_bound)
if start > stop:
raise ValueError
elif start < stop:
if start < stop:
if aslice.step:
my_range = range(start, stop, aslice.step)
else:
Expand All @@ -81,8 +81,7 @@ def excel_cell_position(pos_chars: str) -> Tuple[int, int]:

if match:
return int(match.group(2)) - 1, excel_column_index(match.group(1))
else:
raise KeyError(f"invalid index: {pos_chars}")
raise KeyError(f"invalid index: {pos_chars}")


"""
Expand Down Expand Up @@ -119,6 +118,4 @@ def names_to_indices(names, series):
def abs(value):
if value < 0:
return value * -1

else:
return value
return value
5 changes: 2 additions & 3 deletions pyexcel/internal/sheets/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __getitem__(self, aslice):
if is_sheet:
return self._ref.named_column_at(aslice)

elif isinstance(aslice, slice):
if isinstance(aslice, slice):
my_range = utils.analyse_slice(
aslice, self._ref.number_of_columns()
)
Expand All @@ -242,8 +242,7 @@ def __getitem__(self, aslice):
if utils.abs(index) in self._ref.column_range():
return self._ref.column_at(index)

else:
raise IndexError
raise IndexError

def __iadd__(self, other):
"""Overload += sign
Expand Down
2 changes: 1 addition & 1 deletion pyexcel/internal/sheets/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datetime
from decimal import Decimal

from pyexcel import constants as constants
from pyexcel import constants


def string_to_format(value, target_format):
Expand Down

0 comments on commit f1bf5fe

Please sign in to comment.