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

Typing #197

Merged
merged 39 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9b6f837
add: mypy configuration
eggplants Jan 24, 2022
8b64d35
add: type hinting
eggplants Jan 24, 2022
7933e14
fix: all mypy errors
eggplants Jan 24, 2022
50ad790
fix: redundant import and test error
eggplants Jan 24, 2022
0edbdf1
Merge branch 'master' of https://github.com/RDFLib/sparqlwrapper into…
eggplants Jan 24, 2022
6cb82c6
Merge branch 'RDFLib-master' into typing
eggplants Jan 24, 2022
6a97abe
add: pandas to deps
eggplants Jan 24, 2022
71a6a85
fix
eggplants Jan 24, 2022
ef9c374
fix
eggplants Jan 24, 2022
0d02daa
rm: useless file
eggplants Jan 27, 2022
9d251a8
Merge branch 'master' into typing
nicholascar Feb 17, 2022
41c7934
add: `show_error_codes = True` to mypy configuration
eggplants Feb 17, 2022
b4174bb
Merge branch 'typing' of https://github.com/eggplants/sparqlwrapper i…
eggplants Feb 17, 2022
62362cb
fix: replace refs from __init__.py by `attr:` with hardcoded values
eggplants Feb 17, 2022
eed2f88
fix
eggplants Feb 17, 2022
3f4dd7a
fix: pandas import error and add pandas to extras_require
eggplants Feb 17, 2022
a09e44f
fix: move pandas into install_requires
eggplants Feb 17, 2022
ef952a7
Revert "fix: move pandas into install_requires"
eggplants Feb 17, 2022
e9a077e
fix: replace pd.DataFrame in returned type hint with Any to avoid imp…
eggplants Feb 17, 2022
11b674f
fix: remove pandas from requirements.txt
eggplants Feb 18, 2022
dc4d5c9
add: requirements.optional.txt
eggplants Feb 18, 2022
adfa35f
rm: useless info from init
eggplants Feb 19, 2022
b193f3c
add: more warnings to mypy conf
eggplants Feb 19, 2022
428ce92
add: mypy
eggplants Feb 19, 2022
f1c4bbc
fix: ignore missing-import of pandas
eggplants Feb 19, 2022
4cd53d7
fix: typing of pandas
eggplants Feb 19, 2022
e5211bc
Merge branch 'typing' of https://github.com/eggplants/sparqlwrapper i…
eggplants Feb 19, 2022
230a029
fix: undo class order Wrapper.py and quote some returned types
eggplants Feb 19, 2022
20253a2
add: specify target dir as mypy target in conf
eggplants Feb 20, 2022
fb1949f
fix: ci
eggplants Feb 20, 2022
7dc98eb
fix: typever in KeyCaseInsensitiveDict
eggplants Feb 20, 2022
485eaa6
fix: argument type of KeyCaseInsensitiveDict initializer
eggplants Feb 20, 2022
f467d40
add: pandas-stubs to dev deps
eggplants Feb 20, 2022
90cff98
fix
eggplants Feb 20, 2022
95a5030
revert changes potensially break behavior
eggplants Feb 20, 2022
8daf648
fix: ci
eggplants Feb 20, 2022
ac817dc
Remove some changes which are not needed for type checking
aucampia Feb 20, 2022
51805ba
Don't import rdflib globally
aucampia Feb 20, 2022
8cc80aa
rely on config for specifying what to check
aucampia Feb 20, 2022
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
10 changes: 1 addition & 9 deletions SPARQLWrapper/sparql_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io
from typing import Dict, List, Union

import pandas as pd
import rdflib.term

from SPARQLWrapper.SmartWrapper import Bindings, SPARQLWrapper2, Value
Expand All @@ -16,9 +17,6 @@ class QueryException(Exception):

def get_sparql_dataframe_orig(endpoint: str, query: Union[str, bytes]) -> pd.DataFrame:
"""copy paste from: https://github.com/lawlesst/sparql-dataframe"""
# pandas inside to avoid requiring it
import pandas as pd

sparql = SPARQLWrapper(endpoint)
sparql.setQuery(query)
if sparql.queryType != SELECT:
Expand All @@ -36,9 +34,6 @@ def get_sparql_typed_dict(
endpoint: str, query: Union[str, bytes]
) -> List[Dict[str, Value]]:
"""modified from: https://github.com/lawlesst/sparql-dataframe"""
# pandas inside to avoid requiring it
import pandas as pd

sparql = SPARQLWrapper2(endpoint)
sparql.setQuery(query)
if sparql.queryType != SELECT:
Expand All @@ -61,9 +56,6 @@ def get_sparql_typed_dict(


def get_sparql_dataframe(endpoint: str, query: Union[str, bytes]) -> pd.DataFrame:
# pandas inside to avoid requiring it
import pandas as pd

d = get_sparql_typed_dict(endpoint, query)
# TODO: will nan fill somehow, make more strict if there is way of getting the nan types from rdflib
df = pd.DataFrame(d)
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ packages =
include_package_data = True
install_requires =
rdflib>=6.1.1
pandas>=1.3.5
nicholascar marked this conversation as resolved.
Show resolved Hide resolved
python_requires = >= 3.7

[options.extras_require]
dev =
setuptools>=3.7.1
pandas =
pandas>=1.3.5
keepalive =
keepalive>=0.5
nicholascar marked this conversation as resolved.
Show resolved Hide resolved

Expand Down