internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: frappe/hrms

Issue:
Incorrect LWP Calculation for Leave Types Including Holidays on Salary Slip
### Information about bug

The `calculate_lwp_or_ppl_based_on_leave_application` function in the Salary Slip has a bug related to calculating Leave Without Pay (LWP) when leave types include holidays. The issue stems from referencing the incorrect attribute name (`include_holidays` instead of `include_holiday`) in the function's logic.

### Proposed Solution
Update the attribute name from `include_holidays` to `include_holiday` in the `calculate_lwp_or_ppl_based_on_leave_application` function.


### Module

Payroll

### Version

- Frappe : v15.18.2
- ERPNext: v15.17.5
- HRMS:  v15.14.2

### Installation method

FrappeCloud

### Relevant log output / Stack trace / Full Error Message.

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct


Discussion:

Resolving patch:
diff --git a/hrms/payroll/doctype/salary_slip/salary_slip.py b/hrms/payroll/doctype/salary_slip/salary_slip.py
--- a/hrms/payroll/doctype/salary_slip/salary_slip.py
+++ b/hrms/payroll/doctype/salary_slip/salary_slip.py
@@ -605,7 +605,7 @@ def calculate_lwp_or_ppl_based_on_leave_application(
 			if not leave:
 				continue
 
-			if not leave.include_holidays and getdate(d) in holidays:
+			if not leave.include_holiday and getdate(d) in holidays:
 				continue
 
 			equivalent_lwp_count = 0


Test patch:
Repository: frappe/hrms

Issue:
Incorrect LWP Calculation for Leave Types Including Holidays on Salary Slip
### Information about bug

The `calculate_lwp_or_ppl_based_on_leave_application` function in the Salary Slip has a bug related to calculating Leave Without Pay (LWP) when leave types include holidays. The issue stems from referencing the incorrect attribute name (`include_holidays` instead of `include_holiday`) in the function's logic.

### Proposed Solution
Update the attribute name from `include_holidays` to `include_holiday` in the `calculate_lwp_or_ppl_based_on_leave_application` function.


### Module

Payroll

### Version

- Frappe : v15.18.2
- ERPNext: v15.17.5
- HRMS:  v15.14.2

### Installation method

FrappeCloud

### Relevant log output / Stack trace / Full Error Message.

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct


Discussion:
Fixes #1574 

Resolving patch:
diff --git a/hrms/payroll/doctype/salary_slip/salary_slip.py b/hrms/payroll/doctype/salary_slip/salary_slip.py
--- a/hrms/payroll/doctype/salary_slip/salary_slip.py
+++ b/hrms/payroll/doctype/salary_slip/salary_slip.py
@@ -605,7 +605,7 @@ def calculate_lwp_or_ppl_based_on_leave_application(
 			if not leave:
 				continue
 
-			if not leave.include_holidays and getdate(d) in holidays:
+			if not leave.include_holiday and getdate(d) in holidays:
 				continue
 
 			equivalent_lwp_count = 0


Test patch:
Repository: plotly/dash

Issue:
Do not encourage Flask.run in production
I'm not entirely clear if this is even meant for deployed applications, since the docs don't get into that. The Werkzeug dev server is not guaranteed to be efficient, stable, or secure. Your guide should mention that `Dash.run_server` should only be used during development.

Another option would be to use Gunicorn in `Dash.run_server` instead of `Flask.run`, and not make your users decide.

If you don't want to write your own deploy docs, you can point at http://flask.pocoo.org/docs/dev/deploying/ and mention that the app instance is `Dash.server`. Since they have the option to serve static files locally, you should also mention serving them with the web server instead of Flask in that case.

Additionally, it is dangerous to enable debug mode by default, since that enables the interactive debugger. Since that's not mentioned in your docs, users may inadvertently expose themselves by calling `run_server` and binding to the outside world. Your docs already do `run_server(debug=True)` in most places, so simply changing the default would be safer.


Discussion:
Thanks for opening @davidism ! Yes, `run_server` is not intended for production use, `gunicorn` is. I'll add this to the docs on deployment.

Good suggestion on `run_server` too. I'll change that default now. 

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -603,7 +603,7 @@ def _setup_server(self):
 
     def run_server(self,
                    port=8050,
-                   debug=True,
+                   debug=False,
                    threaded=True,
                    **flask_run_options):
         self.server.run(port=port, debug=debug, **flask_run_options)


Test patch:
Repository: plotly/dash

Issue:
Functions running too often on page load and callback
On page load, Dash serves the initial layout (when provided in a function) more than once. I've seen it run one of my "initial" functions at least 20 times. Likewise, if you have 5 inputs, a callback's function is running 5 times even if not all of those inputs have changed or fired. Caching has helped, but it still seems really inefficient and others have noticed similar behaviour.

Have a look [here for more details](https://community.plot.ly/t/many-updates-on-one-page-load-dash-app/4743). 


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -108,6 +108,7 @@ def __init__(
         self.server.before_first_request(self._setup_server)
 
         self._layout = None
+        self._cached_layout = None
         self.routes = []
 
     class config:
@@ -119,9 +120,10 @@ def layout(self):
 
     def _layout_value(self):
         if isinstance(self._layout, collections.Callable):
-            return self._layout()
+            self._cached_layout = self._layout()
         else:
-            return self._layout
+            self._cached_layout = self._layout
+        return self._cached_layout
 
     @layout.setter
     def layout(self, value):
@@ -134,8 +136,10 @@ def layout(self, value):
                 'a dash component.')
 
         self._layout = value
-        self.css._update_layout(value)
-        self.scripts._update_layout(value)
+
+        layout_value = self._layout_value()
+        self.css._update_layout(layout_value)
+        self.scripts._update_layout(layout_value)
         self._collect_and_register_resources(
             self.scripts.get_all_scripts()
         )
@@ -324,7 +328,8 @@ def react(self, *args, **kwargs):
             'so make sure to call `help(app.callback)` to learn more.')
 
     def _validate_callback(self, output, inputs, state, events):
-        layout = self._layout_value()
+        layout = self._cached_layout or self._layout_value()
+
         if (layout is None and
                 not self.config.supress_callback_exceptions):
             # Without a layout, we can't do validation on the IDs and
diff --git a/dash/resources.py b/dash/resources.py
--- a/dash/resources.py
+++ b/dash/resources.py
@@ -1,7 +1,6 @@
 from copy import copy
 import json
 import warnings
-import collections
 
 from .development.base_component import Component
 
@@ -64,10 +63,7 @@ def get_all_resources(self):
     def get_inferred_resources(self):
         namespaces = []
         resources = []
-        if isinstance(self.layout, collections.Callable):
-            layout = self.layout()
-        else:
-            layout = self.layout
+        layout = self.layout
 
         def extract_resource_from_component(component):
             if (isinstance(component, Component) and
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.18.0'
+__version__ = '0.18.1'


Test patch:
Repository: plotly/dash

Issue:
Falsey values ("", 0, [], {},  False) are as bad as None
In these instances, all other falsey values ("", 0, [], {},  False, etc.) are just as dangerous as `None` so we should treat them as if they were `None`.

This approach replaces an empty `name` with 'dash' even if the caller provides a `server`.


Discussion:
fwiw this looks good, and fixes the `name` bug too.
Hey, why this has not been merged yet ? Bye 👋

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -35,13 +35,9 @@ def __init__(
                 See https://github.com/plotly/dash/issues/141 for details.
                 ''', DeprecationWarning)
 
+        name = name or 'dash'
         # allow users to supply their own flask server
-        if server is not None:
-            self.server = server
-        else:
-            if name is None:
-                name = 'dash'
-            self.server = Flask(name, static_folder=static_folder)
+        self.server = server or Flask(name, static_folder=static_folder)
 
         self.url_base_pathname = url_base_pathname
         self.config = _AttributeDict({


Test patch:
Repository: plotly/dash

Issue:
Cache-busting URLs for CSS included in the assets folder
See https://github.com/plotly/dash/pull/286#discussion_r201812562 for context


Discussion:
Here's another option: In debug or dev_mode, let's set the cache headers to not cache anything in a `after_request` handler.

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -302,7 +302,8 @@ def _relative_url_path(relative_package_path='', namespace=''):
                 )
             elif 'asset_path' in resource:
                 static_url = flask.url_for('assets.static',
-                                           filename=resource['asset_path'])
+                                           filename=resource['asset_path'],
+                                           mod=resource['ts'])
                 srcs.append(static_url)
         return srcs
 
@@ -863,8 +864,8 @@ def _walk_assets_directory(self):
         walk_dir = self._assets_folder
         slash_splitter = re.compile(r'[\\/]+')
 
-        def add_resource(p):
-            res = {'asset_path': p}
+        def add_resource(p, filepath):
+            res = {'asset_path': p, 'filepath': filepath}
             if self.config.assets_external_path:
                 res['external_url'] = '{}{}'.format(
                     self.config.assets_external_path, path)
@@ -887,10 +888,13 @@ def add_resource(p):
                 else:
                     path = f
 
+                full = os.path.join(current, f)
+
                 if f.endswith('js'):
-                    self.scripts.append_script(add_resource(path))
+                    self.scripts.append_script(
+                        add_resource(path, full))
                 elif f.endswith('css'):
-                    self.css.append_css(add_resource(path))
+                    self.css.append_css(add_resource(path, full))
                 elif f == 'favicon.ico':
                     self._favicon = path
 
diff --git a/dash/resources.py b/dash/resources.py
--- a/dash/resources.py
+++ b/dash/resources.py
@@ -1,6 +1,7 @@
 from copy import copy
 import json
 import warnings
+import os
 
 from .development.base_component import Component
 
@@ -30,7 +31,9 @@ def _filter_resources(self, all_resources):
             elif 'absolute_path' in s:
                 filtered_resource['absolute_path'] = s['absolute_path']
             elif 'asset_path' in s:
+                info = os.stat(s['filepath'])
                 filtered_resource['asset_path'] = s['asset_path']
+                filtered_resource['ts'] = info.st_mtime
             elif self.config.serve_locally:
                 warnings.warn(
                     'A local version of {} is not available'.format(
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.23.1'
+__version__ = '0.24.0'


Test patch:
Repository: plotly/dash

Issue:
Allow for defining ignored files from `assets/` that should not be automatically served
I have couple of available color pallets on my site, the `app.callback` changes the `href` value of corresponding `html.Link` when user picks another option. I would like to keep all my styles (default ones + colors defining) in single directory, it would be nice to have some way to define ignored files, of best regexp that will define ignored filename from the assets directory as in case like this including all styles in the `<head>` will not work.


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -73,9 +73,10 @@ def __init__(
             static_folder='static',
             assets_folder=None,
             assets_url_path='/assets',
+            assets_ignore='',
+            include_assets_files=True,
+            url_base_pathname='/',
             assets_external_path=None,
-            include_assets_files=None,
-            url_base_pathname=None,
             requests_pathname_prefix=None,
             routes_pathname_prefix=None,
             compress=True,
@@ -158,6 +159,8 @@ def _handle_error(error):
         self._external_scripts = external_scripts or []
         self._external_stylesheets = external_stylesheets or []
 
+        self.assets_ignore = assets_ignore
+
         self.registered_paths = {}
 
         # urls
@@ -895,6 +898,8 @@ def _setup_server(self):
     def _walk_assets_directory(self):
         walk_dir = self._assets_folder
         slash_splitter = re.compile(r'[\\/]+')
+        ignore_filter = re.compile(self.assets_ignore) \
+            if self.assets_ignore else None
 
         def add_resource(p, filepath):
             res = {'asset_path': p, 'filepath': filepath}
@@ -914,7 +919,10 @@ def add_resource(p, filepath):
                 else:
                     base = splitted[0]
 
-            for f in sorted(files):
+            files_gen = (x for x in files if not ignore_filter.search(x)) \
+                if ignore_filter else files
+
+            for f in sorted(files_gen):
                 if base:
                     path = '/'.join([base, f])
                 else:
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.25.1'
+__version__ = '0.26.0'


Test patch:
diff --git a/tests/assets/load_ignored.js b/tests/assets/load_ignored.js
new file mode 100644
--- /dev/null
+++ b/tests/assets/load_ignored.js
@@ -0,0 +1 @@
+window.tested = 'IGNORED'; // Break the chain.
\ No newline at end of file
diff --git a/tests/test_integration.py b/tests/test_integration.py
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -363,7 +363,8 @@ def test_index_customization(self):
         self.percy_snapshot('custom-index')
 
     def test_assets(self):
-        app = dash.Dash(assets_folder='tests/assets')
+        app = dash.Dash(assets_folder='tests/assets',
+                        assets_ignore='.*ignored.*')
         app.index_string = '''
         <!DOCTYPE html>
         <html>
Repository: plotly/dash

Issue:
The README is in markdown and doesn't render properly on pypi.io
See: https://pypi.org/project/dash/



Discussion:
PyPi now support markdown, but some changes to setup.py are needed: https://stackoverflow.com/a/26737258/467314
Nice, thanks! Would you be willing to make a PR with that change? It looks like it'd be 1-liner

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -14,6 +14,7 @@
     description=('A Python framework for building reactive web-apps. '
                  'Developed by Plotly.'),
     long_description=io.open('README.md', encoding='utf-8').read(),
+    long_description_content_type='text/markdown',
     install_requires=[
         'Flask>=0.12',
         'flask-compress',


Test patch:
Repository: plotly/dash

Issue:
The new Blueprint-based assets breaks when two Dash apps try to use the same Flask instance
This was reported on the [community forums](https://community.plot.ly/t/a-name-collision-occurred-between-blueprints-on-dash-v0-22-0/12795).

```python
import flask
import dash
import dash_html_components as html

server = flask.Flask(__name__)

app1 = dash.Dash(server=server, url_base_pathname='/app1/')
app1.layout = html.Div('app1')

app2 = dash.Dash(server=server, url_base_pathname='/app2/')
app2.layout = html.Div('app2')

if __name__ == '__main__':
    server.run()
```

The above example yields this error:

> AssertionError: A name collision occurred between blueprints <flask.blueprints.Blueprint object at 0x7f945444ce80> and <flask.blueprints.Blueprint object at 0x7f943caa8278>. Both share the same name "assets". Blueprints that are created on the fly need unique names.



Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -104,10 +104,11 @@ def __init__(
         # allow users to supply their own flask server
         self.server = server or Flask(name, static_folder=static_folder)
 
-        self.server.register_blueprint(
-            flask.Blueprint('assets', 'assets',
-                            static_folder=self._assets_folder,
-                            static_url_path=assets_url_path))
+        if 'assets' not in self.server.blueprints:
+            self.server.register_blueprint(
+                flask.Blueprint('assets', 'assets',
+                                static_folder=self._assets_folder,
+                                static_url_path=assets_url_path))
 
         env_configs = _configs.env_configs()
 
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.26.1'
+__version__ = '0.26.2'


Test patch:
Repository: plotly/dash

Issue:
Assets don't work for Dash apps created with an existing Flask server
This is because the `name` param is taken to be the default value from the constructor (namely `__main__`), even if a Flask instance is provided. In this case, the `name` used to locate the base path of the package should be updated to be the `name` attribute of the Flask instance.


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -96,6 +96,7 @@ def __init__(
                 See https://github.com/plotly/dash/issues/141 for details.
                 ''', DeprecationWarning)
 
+        name = name if server is None else server.name
         self._assets_folder = assets_folder or os.path.join(
             flask.helpers.get_root_path(name), 'assets'
         )


Test patch:
Repository: plotly/dash

Issue:
Dash's config validation prevents `requests_pathname_prefix` and `requests_pathname_prefix` from being set
Trying to supply values for either of `requests_pathname_prefix` and `requests_pathname_prefix` results in an error:

```
dash.exceptions.InvalidConfig:
    You supplied `url_base_pathname` and `requests_pathname_prefix`. This is ambiguous.
    To fix this, set `routes_pathname_prefix` instead of `url_base_pathname`.
```

However I did not supply a value for `url_base_pathname`. Looks like this is because `_configs.pathname_configs` is checking to see if  `url_base_pathname` is not None to indicate that a user supplied their own value, but Dash sets a default value of '/', so this logic doesn't work.


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -76,7 +76,7 @@ def __init__(
             assets_url_path='/assets',
             assets_ignore='',
             include_assets_files=True,
-            url_base_pathname='/',
+            url_base_pathname=None,
             assets_external_path=None,
             requests_pathname_prefix=None,
             routes_pathname_prefix=None,
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.26.3'
+__version__ = '0.26.4'


Test patch:
Repository: plotly/dash

Issue:
Generate class endlines.
When generating classes for the components libs, if you are on windows, the endlines of the docstring will be `\r\n` instead of `\n`. This gives `^m` diff on github when there shouldn't be a difference.


Discussion:
I think we should just add `* text=auto` to `.gitattributes` to the boilerplate since we want all our component repos to be cross platform. https://stackoverflow.com/a/21473084/8807960

I'll see if I can test this by putting some `^m` in a class file, but I don't have a real windows environment to test on
@rmarren1 I'll try it from my machine.

Resolving patch:
diff --git a/dash/development/base_component.py b/dash/development/base_component.py
--- a/dash/development/base_component.py
+++ b/dash/development/base_component.py
@@ -361,7 +361,7 @@ def __repr__(self):
         component_name=typename,
         props=filtered_props,
         events=parse_events(props),
-        description=description)
+        description=description).replace('\r\n', '\n')
 
     # pylint: disable=unused-variable
     events = '[' + ', '.join(parse_events(props)) + ']'
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.28.4'
+__version__ = '0.28.5'


Test patch:
Repository: plotly/dash

Issue:
Dash.registered_paths appending package path on every index access.
This code append the relative_package_path every time the index is accessed, taking up memory:
https://github.com/plotly/dash/blob/61b05450ed562923f7d5b67842c9b04c899c4928/dash/dash.py#L316-L319

Should be a `collections.defaultdict(set)` instead.



Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -167,7 +167,7 @@ def _handle_error(error):
 
         self.assets_ignore = assets_ignore
 
-        self.registered_paths = {}
+        self.registered_paths = collections.defaultdict(set)
 
         # urls
         self.routes = []
@@ -313,10 +313,7 @@ def _collect_and_register_resources(self, resources):
         def _relative_url_path(relative_package_path='', namespace=''):
 
             # track the registered packages
-            if namespace in self.registered_paths:
-                self.registered_paths[namespace].append(relative_package_path)
-            else:
-                self.registered_paths[namespace] = [relative_package_path]
+            self.registered_paths[namespace].add(relative_package_path)
 
             module_path = os.path.join(
                 os.path.dirname(sys.modules[namespace].__file__),
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = '0.28.5'
+__version__ = '0.28.6'


Test patch: