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

Update mypy and pylint #96

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/beancount-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- run: pip install -r requirements_dev.txt
- run: pylint beanprice
- run: pytest beanprice
- run: mypy beanprice --ignore-missing-imports
- run: mypy beanprice
54 changes: 9 additions & 45 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ load-plugins=
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no

# Tells whether to display a full report or only the messages
reports=no

Expand Down Expand Up @@ -85,8 +80,6 @@ disable=locally-disabled,
too-many-function-args,
unsubscriptable-object,
too-many-nested-blocks,
no-self-use,
redefined-variable-type,
duplicate-code,
too-few-public-methods,
too-many-public-methods,
Expand Down Expand Up @@ -120,7 +113,14 @@ disable=locally-disabled,
c-extension-no-member,
cyclic-import,
isinstance-second-argument-not-valid-type,
bad-continuation
missing-timeout,
consider-using-f-string,
consider-using-with,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
too-many-positional-arguments,
possibly-used-before-assignment,
arguments-renamed

# Notes:
# bad-continuation: Is buggy, see https://github.com/PyCQA/pylint/issues/3512
Expand Down Expand Up @@ -177,9 +177,6 @@ notes=FIXME,XXX,TODO

[BASIC]

# List of builtins function names that should not be used, separated by a comma
bad-functions=

# Good variable names which should always be accepted, separated by a comma
good-names=f,i,j,k,ex,Run,_

Expand All @@ -196,63 +193,33 @@ include-naming-hint=no
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_\-]*)|([A-Z][a-zA-Z0-9]+))$

# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Regular expression matching correct method names
method-rgx=[a-z_][a-zA-Z0-9_]{2,72}$

# Naming hint for method names
method-name-hint=[a-z_][a-zA-Z0-9_]{2,64}$

# Regular expression matching correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$

# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$

# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$

# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$

# Regular expression matching correct variable names
variable-rgx=(_?[a-z_][a-z0-9_]{2,30}|__|mu|no)$

# Naming hint for variable names
variable-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Regular expression matching correct attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for attribute names
attr-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct argument names
argument-rgx=(_?[a-z_][a-z0-9_]{2,30}|__|mu)$

# Naming hint for argument names
argument-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct function names
function-rgx=_?[a-z_][a-zA-Z0-9_]{2,64}$

# Naming hint for function names
function-name-hint=[a-z_][a-zA-Z0-9_]{2,64}$

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=__.*__
Expand All @@ -274,9 +241,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# else.
single-line-if-stmt=no

# List of optional constructs for which whitespace checking is disabled
no-space-check=trailing-comma,dict-separator

# Maximum number of lines in a module
max-module-lines=1000

Expand Down Expand Up @@ -375,4 +339,4 @@ valid-metaclass-classmethod-first-arg=mcs

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pylint beanprice
Type checker:

```
mypy beanprice --ignore-missing-imports
mypy beanprice
```

## Copyright and License
Expand Down
12 changes: 9 additions & 3 deletions beanprice/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def import_source(module_name: str):


def find_currencies_declared(
entries: data.Entries, date: datetime.date = None
entries: data.Entries,
date: Optional[datetime.date] = None,
) -> List[Tuple[str, str, List[PriceSource]]]:
"""Return currencies declared in Commodity directives.

Expand Down Expand Up @@ -564,7 +565,7 @@ def setup_cache(cache_filename: Optional[str], clear_cache: bool):
flag = "n"

global _CACHE
_CACHE = shelve.open(cache_filename, flag=flag)
_CACHE = shelve.open(cache_filename, flag=flag) # type: ignore
_CACHE.expiration = DEFAULT_EXPIRATION # type: ignore


Expand Down Expand Up @@ -671,7 +672,12 @@ def filter_redundant_prices(
return filtered_prices, ignored_prices


def process_args() -> Tuple[Any, List[DatedPrice], List[data.Price], Any]:
def process_args() -> Tuple[
argparse.Namespace,
List[DatedPrice],
data.Directives,
Optional[Any],
]:
"""Process the arguments. This also initializes the logging module.

Returns:
Expand Down
4 changes: 2 additions & 2 deletions beanprice/price_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def test_source_map_onecur_multiple(self):
)

def test_source_map_manycur_single(self):
smap = price.parse_source_map("USD:yahoo/USDCAD " "CAD:yahoo/CAD=X")
smap = price.parse_source_map("USD:yahoo/USDCAD CAD:yahoo/CAD=X")
self.assertEqual(
{
"USD": [PS("beanprice.sources.yahoo", "USDCAD", False)],
Expand All @@ -422,7 +422,7 @@ def test_source_map_manycur_single(self):
)

def test_source_map_manycur_multiple(self):
smap = price.parse_source_map("USD:yahoo/GBPUSD,oanda/GBPUSD " "CAD:yahoo/GBPCAD")
smap = price.parse_source_map("USD:yahoo/GBPUSD,oanda/GBPUSD CAD:yahoo/GBPCAD")
self.assertEqual(
{
"USD": [
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ ignore = [
'UP007',
'UP032',
]

[tool.mypy]
disable_error_code = ["import-untyped"]
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r requirements.txt
pylint==2.7.2
pylint==3.3.3
pytest==5.4.2
mypy==0.812
mypy==1.14.1
Loading