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

revert black #97

Merged
merged 8 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 4 additions & 4 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[bumpversion]
current_version = (0, 0, 6, "final", 0)
current_version = 0, 3, 0, 'final', 0
commit = True
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+)
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \'(?P<release>\S+)\'\,\ (?P<build>\d+)
serialize =
{major}, {minor}, {patch}, "{release}", {build}
{major}, {minor}, {patch}, '{release}', {build}

[bumpversion:part:release]
optional_value = final
Expand All @@ -22,4 +22,4 @@ search = "version": "{current_version}"
replace = "version": "{new_version}"
serialize =
{major}.{minor}.{patch}-{release}.{build}
{major}.{minor}.{patch}
{major}.{minor}.{patch}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ lint: ## run linter
fixjs: ## run autopep8/tslint fix
cd js; ${YARN} fix

fixpy: ## run black
${PYTHON} -m black jupyterfs/ setup.py
fixpy: ## run autopep8
${PYTHON} -m autopep8 --in-place -r -a -a jupyterfs/ setup.py

fix: ## run autopep8/tslint fix
make fixjs
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip install jupyter-fs

## Configure

Add the following to your `jupyter_notebook_config.json`:
Add the following to your `jupyter_server_config.json`:

```json
{
Expand Down Expand Up @@ -123,7 +123,7 @@ The `"url"` field jupyter-fs config is based on the PyFilesystem [opener url](ht

## Server-side settings

If you prefer to set up your filesystem resources in the server-side config, you can do so. For example, you can set up a local filesystem by adding the following to your `jupyter_lab_config.py` file:
If you prefer to set up your filesystem resources in the server-side config, you can do so. For example, you can set up a local filesystem by adding the following to your `jupyter_server_config.py` file:

```python
c.Jupyterfs.resources = [
Expand All @@ -134,7 +134,7 @@ c.Jupyterfs.resources = [
]
```

ALternatively, you can add resource specifications alongside the basic jupyter-fs config in your `jupyter_lab_config.json` file:
ALternatively, you can add resource specifications alongside the basic jupyter-fs config in your `jupyter_server_config.json` file:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ parameters:
- script: make lintjs YARN=yarn
displayName: 'Lint JS'

- bash: pip install flake8 flake8-black
- bash: pip install flake8
displayName: 'Install Python lint deps'

- script: make lintpy
Expand Down
28 changes: 12 additions & 16 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"jupyterlab-extension"
],
"scripts": {
"build": "tsc --jsx react",
"build": "tsc -b",
"build:integrity": "yarn install && yarn deduplicate && yarn install && yarn build",
"build:labdist": "yarn clean:labdist && yarn build:integrity && mkdirp ../jupyterfs/labdist && cd ../jupyterfs/labdist && npm pack ../../js",
"clean": "rimraf lib tsconfig.tsbuildinfo *junit.xml coverage* .jupyter",
"clean:more": "yarn clean && rimraf build dist MANIFEST",
"clean:labdist": "rimraf ../jupyterfs/labdist",
"clean:slate": "yarn clean:more && yarn clean:labdist && rimraf node_modules",
"deduplicate": "yarn yarn-deduplicate -s fewer yarn.lock || yarn yarn-deduplicate -s fewer",
"deduplicate": "yarn yarn-deduplicate -s fewer ../yarn.lock || yarn yarn-deduplicate -s fewer",
"fix": "yarn lint --fix",
"lint": "eslint -c .eslintrc.js --ext .js,.ts,.tsx src/",
"lint": "eslint -c .eslintrc.js --ext .js,.ts,.tsx src/ tests/",
"postpack": "shx rm README.md",
"prepack": "shx cp ../README.md .",
"prepublishOnly": "yarn run build",
Expand Down Expand Up @@ -65,20 +65,20 @@
"@jupyterlab/ui-components": "^3.0.0",
"@lumino/algorithm": "^1.3.3",
"@lumino/disposable": "^1.4.3",
"@material-ui/core": "4.10.2",
"@material-ui/core": "^4.11.3",
"@types/file-saver": "^2.0.1",
"@types/jszip": "^3.1.6",
"file-saver": "^2.0.2",
"jszip": "^3.2.2",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"@types/jszip": "^3.4.1",
"file-saver": "^2.0.5",
"jszip": "^3.6.0",
"react": "^17.0.0",
"react-dom": "^17.0.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.7.6",
"@types/jest": "^24",
"@types/react": "^16.9.38",
"@types/react-dom": "^16.9.8",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^7.0.0",
Expand All @@ -94,11 +94,7 @@
"rimraf": "^2.7.1",
"shx": "^0.3.3",
"ts-jest": "~25.2.1",
"typescript": "^3.9.0",
"typescript": "^4.2.3",
"yarn-deduplicate": "^3.1.0"
},
"resolutions": {
"node-fetch": "^2.6.1",
"node-notifier": "^8.0.1"
}
}
4 changes: 2 additions & 2 deletions js/src/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ abstract class FSCommBase implements IFSComm {
}
}

abstract async getResourcesRequest(): Promise<IFSResource[]>;
abstract async initResourceRequest(args: {options: IFSOptions; resources: IFSResource[]}): Promise<IFSResource[]>;
abstract getResourcesRequest(): Promise<IFSResource[]>;
abstract initResourceRequest(args: {options: IFSOptions; resources: IFSResource[]}): Promise<IFSResource[]>;

get baseUrl(): string {
return this.settings.baseUrl;
Expand Down
30 changes: 19 additions & 11 deletions js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"jsx": "react",
"allowSyntheticDefaultImports": true,
"composite": true,
"declaration": true,
"noImplicitAny": true,
"esModuleInterop": true,
"incremental": true,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"allowSyntheticDefaultImports": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES6",
"outDir": "./lib",
"skipLibCheck": true,
"lib": ["es5", "es2015.promise", "dom", "es2015.collection", "es2015.iterable"],
"types": ["jest", "node"]
"preserveWatchOutput": true,
"resolveJsonModule": true,
"sourceMap": true,
// "strictNullChecks": true,
"target": "es2018",
// "types": ["jest"],

"outDir": "lib",
"rootDir": "src"
},
"include": ["src/*"]
"include": ["src/**/*"]
}
6 changes: 6 additions & 0 deletions js/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"rootDir": "."
}
}
25 changes: 13 additions & 12 deletions jupyterfs/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@

from collections import namedtuple

VersionInfo = namedtuple(
"VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]
)
VersionInfo = namedtuple('VersionInfo', [
'major',
'minor',
'micro',
'releaselevel',
'serial'
])

# DO NOT EDIT THIS DIRECTLY! It is managed by bumpversion
version_info = VersionInfo(0, 0, 6, "final", 0)
version_info = VersionInfo(0, 3, 0, 'final', 0)

_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}

__version__ = "{}.{}.{}{}".format(
__version__ = '{}.{}.{}{}'.format(
version_info.major,
version_info.minor,
version_info.micro,
(
""
if version_info.releaselevel == "final"
else _specifier_[version_info.releaselevel] + str(version_info.serial)
),
)
(''
if version_info.releaselevel == 'final'
else _specifier_[version_info.releaselevel] + str(version_info.serial)))
41 changes: 16 additions & 25 deletions jupyterfs/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
import os
from string import Template

__all__ = [
"BraceTemplate",
"DoubleBraceTemplate",
"substituteAsk",
"substituteEnv",
"substituteNone",
]
__all__ = ['BraceTemplate', 'DoubleBraceTemplate', 'substituteAsk', 'substituteEnv', 'substituteNone']


class _BaseTemplate(Template):
Expand All @@ -23,51 +17,48 @@ def tokens(self):


class BraceTemplate(_BaseTemplate):
"""Template subclass that will replace any '{VAR}'"""

delimiter = ""
pattern = r"""
"""Template subclass that will replace any '{VAR}'
"""
delimiter = ''
pattern = r'''
(?:
[^{]{(?P<braced>\S+?)}[^}] | # match anything in single braces
(?P<escaped>a^) | # match nothing
(?P<named>a^) | # match nothing
(?P<invalid>a^) # match nothing
)
"""
'''


class DoubleBraceTemplate(_BaseTemplate):
"""Template subclass that will replace any '{{VAR}}'"""

delimiter = ""
pattern = r"""
"""Template subclass that will replace any '{{VAR}}'
"""
delimiter = ''
pattern = r'''
(?:
{{(?P<braced>\S+?)}} | # match anything in double braces
(?P<escaped>a^) | # match nothing
(?P<named>a^) | # match nothing
(?P<invalid>a^) # match nothing
)
"""

'''

def substituteAsk(resource):
if "tokenDict" in resource:
url = DoubleBraceTemplate(resource["url"]).substitute(resource.pop("tokenDict"))
if 'tokenDict' in resource:
url = DoubleBraceTemplate(resource['url']).substitute(resource.pop('tokenDict'))
else:
url = resource["url"]
url = resource['url']

# return the substituted string and the names of any missing vars
return url, DoubleBraceTemplate(url).tokens()


def substituteEnv(resource):
url = DoubleBraceTemplate(resource["url"]).substitute(os.environ)
url = DoubleBraceTemplate(resource['url']).substitute(os.environ)

# return the substituted string and the names of any missing vars
return url, DoubleBraceTemplate(url).tokens()


def substituteNone(resource):
url = resource["url"]
url = resource['url']

return url, DoubleBraceTemplate(url).tokens()
4 changes: 2 additions & 2 deletions jupyterfs/browser_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
here = os.path.abspath(os.path.dirname(__file__))


if __name__ == "__main__":
with patch("jupyterlab.browser_check.here", here):
if __name__ == '__main__':
with patch('jupyterlab.browser_check.here', here):
BrowserApp.launch_instance()
6 changes: 1 addition & 5 deletions jupyterfs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# This file is part of the jupyter-fs library, distributed under the terms of
# the Apache License 2.0. The full license can be found in the LICENSE file.
#

from jupyter_server.services.contents.largefilemanager import LargeFileManager
from jupyter_server.services.contents.manager import ContentsManager
from jupyter_server.transutils import _
Expand All @@ -14,14 +13,11 @@

__all__ = ["Jupyterfs"]


class Jupyterfs(Configurable):
root_manager_class = Type(
config=True,
default_value=LargeFileManager,
help=_(
"the root contents manager class to use. Used by the Jupyterlab default filebrowser and elsewhere"
),
help=_("the root contents manager class to use. Used by the Jupyterlab default filebrowser and elsewhere"),
klass=ContentsManager,
)

Expand Down
4 changes: 2 additions & 2 deletions jupyterfs/contents_managers/absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# the Apache License 2.0. The full license can be found in the LICENSE file.
#

from notebook.services.contents.largefilemanager import LargeFileManager
from jupyter_server.services.contents.largefilemanager import LargeFileManager


class AbsolutePathFileManager(LargeFileManager):
"""Handle large file upload."""

def __init__(self, root_dir="", **kwargs):
def __init__(self, root_dir='', **kwargs):
super(AbsolutePathFileManager, self).__init__(**kwargs)
self.root_dir = root_dir
19 changes: 7 additions & 12 deletions jupyterfs/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import warnings

from notebook.utils import url_path_join
from jupyter_server.utils import url_path_join

from ._version import __version__ # noqa: F401
from .metamanager import MetaManager, MetaManagerHandler
Expand All @@ -24,7 +24,7 @@


def _jupyter_server_extension_paths():
return [{"module": "jupyterfs.extension"}]
return [{'module': 'jupyterfs.extension'}]


def load_jupyter_server_extension(nb_server_app):
Expand All @@ -35,18 +35,13 @@ def load_jupyter_server_extension(nb_server_app):
nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
"""
web_app = nb_server_app.web_app
base_url = web_app.settings["base_url"]
host_pattern = ".*$"
base_url = web_app.settings['base_url']
host_pattern = '.*$'

if not isinstance(nb_server_app.contents_manager, MetaManager):
warnings.warn(_mm_config_warning_msg)
return

resources_url = "jupyterfs/resources"
print(
"Installing jupyter-fs resources handler on path %s"
% url_path_join(base_url, resources_url)
)
web_app.add_handlers(
host_pattern, [(url_path_join(base_url, resources_url), MetaManagerHandler)]
)
resources_url = 'jupyterfs/resources'
print('Installing jupyter-fs resources handler on path %s' % url_path_join(base_url, resources_url))
web_app.add_handlers(host_pattern, [(url_path_join(base_url, resources_url), MetaManagerHandler)])
Loading