Skip to content

Commit

Permalink
Merge pull request #97 from jpmorganchase/linting
Browse files Browse the repository at this point in the history
revert black
  • Loading branch information
telamonian authored Mar 31, 2021
2 parents 22bda4c + a20142e commit 1f9f659
Show file tree
Hide file tree
Showing 29 changed files with 1,753 additions and 1,646 deletions.
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
2 changes: 1 addition & 1 deletion js/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
"eslint:recommended",
],
parserOptions: {
project: "tsconfig.json",
project: "tsconfig.eslint.json",
},
plugins: [
"@typescript-eslint",
Expand Down
3 changes: 2 additions & 1 deletion js/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = {
transformIgnorePatterns: ["/node_modules/(?!(@jupyterlab/.*)/)"],
globals: {
"ts-jest": {
tsConfig: "tsconfig.json",
// in tsconfig.test.json, rootDir is parent of both tests and src dirs
tsconfig: "tsconfig.test.json",
},
},
};
34 changes: 15 additions & 19 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/jest": "^26.0.22",
"@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 @@ -88,17 +88,13 @@
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-unicorn": "^20.0.0",
"isomorphic-fetch": "^2.2.1",
"jest": "^25.2.3",
"jest": "^26.6.3",
"jest-raw-loader": "^1.0.1",
"mkdirp": "^0.5.1",
"rimraf": "^2.7.1",
"shx": "^0.3.3",
"ts-jest": "~25.2.1",
"typescript": "^3.9.0",
"ts-jest": "^26.5.4",
"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
10 changes: 10 additions & 0 deletions js/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig",
"include": [
"*",
".*",
"src/**/*",
"style/**/*",
"tests/**/*"
]
}
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": "."
}
}
File renamed without changes.
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
Loading

0 comments on commit 1f9f659

Please sign in to comment.